Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to enable changing the permission of internal repositories. #898

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Nov 27, 2023

Motivation:
Internal repositories are initially created with the internal permission, and I previously restricted the ability to modify this permission. However, users may have valid reasons to adjust the permission settings.

Modifications:

  • Implemented functionality to change the permission of internal repositories.
    • Note: The guest role remains restricted from having any permission on internal repositories.

Result:

  • You can now have the capability to modify the permission settings for internal repositories, excluding the guest role.

Motivation:
Internal repositories are initially created with the [internal](https://github.com/line/centraldogma/blob/0cf273402d70773e0aab1e2b858111a1c1c0f22c/server/src/main/java/com/linecorp/centraldogma/server/metadata/PerRolePermissions.java#L61) permission,
and I previously restricted the ability to modify this permission.
However, users may have valid reasons to adjust the permission settings.

Modifications:
- Implemented functionality to change the permission of internal repositories.
  - Note: The guest role remains restricted from having any permission on internal repositories.

Result:
- You can now have the capability to modify the permission settings for internal repositories, excluding the guest role.
@minwoox minwoox added the defect label Nov 27, 2023
@minwoox minwoox added this to the 0.63.3 milestone Nov 27, 2023
Copy link

codecov bot commented Nov 27, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ee7e250) 66.11% compared to head (ae147fa) 66.07%.

Files Patch % Lines
.../centraldogma/server/metadata/MetadataService.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #898      +/-   ##
============================================
- Coverage     66.11%   66.07%   -0.04%     
+ Complexity     3407     3404       -3     
============================================
  Files           363      363              
  Lines         14117    14121       +4     
  Branches       1509     1511       +2     
============================================
- Hits           9333     9330       -3     
- Misses         3921     3925       +4     
- Partials        863      866       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 411 to 413
if (!guest.isEmpty()) {
throw new UnsupportedOperationException(
"can't give a permission to guest for internal repository: " + repoName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the permission of internalPermissions, should we disallow giving permissions to MEMBER for internal repositories?

private static final PerRolePermissions internalPermissions =
new PerRolePermissions(READ_WRITE, NO_PERMISSION, NO_PERMISSION);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believed we had previously discussed this matter and reached a consensus to delegate permission-granting authority to the owner for members. 😉
internalPermissions is assigned to internal repositories upon creation, and the owner has the discretion to change it at will. While I'm not strongly opposed, I see no compelling reason to restrict granting permissions to members.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.
I was confused that the permission could be also granted to dogma repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, I believe allowing MEMBER access to dogma can potentially allow MEMBERs to "kick" OWNERs out of projects.
I don't really know the distinction of owner and member though. If the meaning is simply to add an extra layer of authority, I guess the current change is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. The dogma repo is restricted from being accessed by any user, so I initially thought this would suffice:

if (user.isAdmin()) {
return unwrap().serve(ctx, req);
}
if (Project.REPO_DOGMA.equals(repoName)) {
return throwForbiddenResponse(ctx, projectName, repoName, "administrator");
}
.

However, for clarity, I believe it's beneficial to explicitly allow changes only to the meta repository.

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @minwoox!

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

final Set<Permission> guest = perRolePermissions.guest();
if (!guest.isEmpty()) {
throw new UnsupportedOperationException(
"can't give a permission to guest for internal repository: " + repoName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I believe this exception will be directly exposed to the end user

Suggested change
"can't give a permission to guest for internal repository: " + repoName);
"Can't give a permission to guest for internal repository: " + repoName);

Comment on lines 411 to 413
if (!guest.isEmpty()) {
throw new UnsupportedOperationException(
"can't give a permission to guest for internal repository: " + repoName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, I believe allowing MEMBER access to dogma can potentially allow MEMBERs to "kick" OWNERs out of projects.
I don't really know the distinction of owner and member though. If the meaning is simply to add an extra layer of authority, I guess the current change is fine.

@minwoox
Copy link
Contributor Author

minwoox commented Nov 28, 2023

Technically, I believe allowing MEMBER access to dogma can potentially allow MEMBERs to "kick" OWNERs out of projects.

dogma can be accessed only by an admin not even by an owner:

if (user.isAdmin()) {
return unwrap().serve(ctx, req);
}
if (Project.REPO_DOGMA.equals(repoName)) {
return throwForbiddenResponse(ctx, projectName, repoName, "administrator");
}
.

@minwoox minwoox merged commit 0afa010 into line:main Nov 29, 2023
@minwoox minwoox deleted the internal_repo_permission branch November 29, 2023 02:09
@minwoox
Copy link
Contributor Author

minwoox commented Nov 29, 2023

Thanks for reviewing. 😉

minwoox added a commit to minwoox/centraldogma that referenced this pull request Nov 30, 2023
Motivation:
Despite having the necessary permissions after line#898, members were unable to access the meta repository.

Modifications:
- Implemented a fix to ensure that members can access the meta repository as intended.

Result:
- Members with appropriate permissions can now successfully access the meta repository.
minwoox added a commit that referenced this pull request Dec 8, 2023
Motivation:
Despite having the necessary permissions after #898, members were unable to access the meta repository.

Modifications:
- Implemented a fix to ensure that members can access the meta repository as intended.

Result:
- Members with appropriate permissions can now successfully access the meta repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants