Change permissions to be branch based
The RefControl class introduces per-branch access control rules. ProjectRight is replaced by RefRight in the database, shifting all current access records to include a reference pattern that matches the previously assumed target namespace. For example, PUSH_HEAD is now matched against refs/heads/*, as is SUBMIT. Although this implementation starts the foundation for per-branch level READ access, it is not fully supported. The Git native protocol exposes all branches to readers, which means users can still fetch the Git objects even if the web UI wouldn't allow them to see the change. This work was a joint effort between Nico and Shawn. Nico started the change and did the bulk of the implementation. Shawn did a bunch of cleanup work near the tail end. Consequently all bugs are Shawn's fault. Bug: issue 60 Change-Id: I62401d80cbb885180614a4f20a945f5611de8986 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
55f3363fce
commit
75afdfdc84
@@ -17,7 +17,7 @@ package com.google.gerrit.sshd.commands;
|
||||
import com.google.gerrit.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.ApprovalCategory;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.reviewdb.ProjectRight;
|
||||
import com.google.gerrit.reviewdb.RefRight;
|
||||
import com.google.gerrit.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.Project.SubmitType;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
@@ -109,12 +109,13 @@ final class AdminCreateProject extends BaseCommand {
|
||||
private void createProject() throws OrmException {
|
||||
final Project.NameKey newProjectNameKey = new Project.NameKey(projectName);
|
||||
|
||||
final ProjectRight.Key prk =
|
||||
new ProjectRight.Key(newProjectNameKey, ApprovalCategory.OWN, ownerId);
|
||||
final ProjectRight pr = new ProjectRight(prk);
|
||||
final RefRight.Key prk =
|
||||
new RefRight.Key(newProjectNameKey, new RefRight.RefPattern("refs/*"),
|
||||
ApprovalCategory.OWN, ownerId);
|
||||
final RefRight pr = new RefRight(prk);
|
||||
pr.setMaxValue((short) 1);
|
||||
pr.setMinValue((short) 1);
|
||||
db.projectRights().insert(Collections.singleton(pr));
|
||||
db.refRights().insert(Collections.singleton(pr));
|
||||
|
||||
final Project newProject = new Project(newProjectNameKey);
|
||||
newProject.setDescription(projectDescription);
|
||||
|
||||
Reference in New Issue
Block a user