Matrix security username/groupname validation required admin permission

even in project-specific permissions.. now require CONFIGURE permission on project
when validating in project settings.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15080 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
mindless committed 2009-02-06 18:10:30 +00:00
1 parent 9b19ec692d
commit af409e35b3
4 files changed
+16 -6

No files matched your search

@@ -1,5 +1,6 @@
package hudson.security;
import hudson.model.AbstractProject;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.JobProperty;
@@ -20,6 +21,7 @@ import net.sf.json.JSONObject;
import org.acegisecurity.acls.sid.Sid;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.QueryParameter;
import com.thoughtworks.xstream.converters.Converter;
@@ -139,10 +141,10 @@ public class AuthorizationMatrixProperty extends JobProperty<Job<?, ?>> {
return p!=Item.CREATE;
}
public void doCheckName(@QueryParameter String value) throws IOException, ServletException {
GlobalMatrixAuthorizationStrategy.DESCRIPTOR.doCheckName(value);
public void doCheckName(StaplerRequest req, StaplerResponse res, @QueryParameter String value) throws IOException, ServletException {
GlobalMatrixAuthorizationStrategy.DESCRIPTOR.doCheckName(value, req.findAncestorObject(AbstractProject.class), AbstractProject.CONFIGURE);
}
}
}
private final class AclImpl extends SidACL {
protected Boolean hasPermission(Sid sid, Permission p) {
@@ -224,8 +224,12 @@ public class GlobalMatrixAuthorizationStrategy extends AuthorizationStrategy {
}
public void doCheckName(@QueryParameter String value ) throws IOException, ServletException {
doCheckName(value, Hudson.getInstance(), Hudson.ADMINISTER);
}
void doCheckName(String value, AccessControlled subject, Permission permission) throws IOException, ServletException {
final String v = value.substring(1,value.length()-1);
new FormFieldValidator(Hudson.ADMINISTER) {
new FormFieldValidator(subject, permission) {
protected void check() throws IOException, ServletException {
SecurityRealm sr = Hudson.getInstance().getSecurityRealm();
String ev = Functions.escape(v);