-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
misc: privilege management v2 transition #3193
base: main
Are you sure you want to change the base?
misc: privilege management v2 transition #3193
Conversation
WalkthroughThe changes update the permission validation and error handling mechanisms across both backend and frontend parts of the application. In the backend, the previous boolean flag used to indicate sufficient privileges has been replaced with a detailed permission boundary object that includes an Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
backend/src/ee/services/permission/permission-fns.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin". (The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…ment-v2-transition
…ment-v2-transition
const { permission: identityRolePermission } = await permissionService.getProjectPermission({ | ||
actor: ActorType.IDENTITY, | ||
actorId: identityId, | ||
projectId: identityProjectMembership.projectId, | ||
actorAuthMethod, | ||
actorOrgId, | ||
actionProjectType: ActionProjectType.Any | ||
}); | ||
const permissionBoundary = validatePermissionBoundary(permission, identityRolePermission); | ||
if (!permissionBoundary.isValid) | ||
throw new ForbiddenRequestError({ | ||
name: "PermissionBoundaryError", | ||
message: "Failed to remove more privileged identity", | ||
details: { missingPermissions: permissionBoundary.missingPermissions } | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is intentional. why do we have to check privilege of actor if we've already verified the actor to have the "Delete identity" project-level permission
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Identity); | ||
|
||
const { permission: identityRolePermission } = await permissionService.getOrgPermission( | ||
ActorType.IDENTITY, | ||
id, | ||
identityOrgMembership.orgId, | ||
actorAuthMethod, | ||
actorOrgId | ||
); | ||
const permissionBoundary = validatePermissionBoundary(permission, identityRolePermission); | ||
if (!permissionBoundary.isValid) | ||
throw new ForbiddenRequestError({ | ||
name: "PermissionBoundaryError", | ||
message: "Failed to update a more privileged identity", | ||
details: { missingPermissions: permissionBoundary.missingPermissions } | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here as well
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Identity); | ||
const { permission: identityRolePermission } = await permissionService.getOrgPermission( | ||
ActorType.IDENTITY, | ||
id, | ||
identityOrgMembership.orgId, | ||
actorAuthMethod, | ||
actorOrgId | ||
); | ||
const permissionBoundary = validatePermissionBoundary(permission, identityRolePermission); | ||
if (!permissionBoundary.isValid) | ||
throw new ForbiddenRequestError({ | ||
name: "PermissionBoundaryError", | ||
message: "Failed to delete more privileged identity", | ||
details: { missingPermissions: permissionBoundary.missingPermissions } | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same concept here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx (1)
40-40
: Consider updating remaining permission checks for consistencyWhile the Groups and Identities tabs have been updated to use specific action types, the Members tab (line 40) and Roles tab (line 61) still use the generic
OrgPermissionActions.Read
. For consistency, consider updating these as well to use their respective specific action types.- isHidden: permission.cannot(OrgPermissionActions.Read, OrgPermissionSubjects.Member), + isHidden: permission.cannot(OrgPermissionMemberActions.Read, OrgPermissionSubjects.Member),- isHidden: permission.cannot(OrgPermissionActions.Read, OrgPermissionSubjects.Role), + isHidden: permission.cannot(OrgPermissionRoleActions.Read, OrgPermissionSubjects.Role),Also applies to: 61-61
backend/src/ee/services/permission/permission-fns.ts (1)
52-55
: Clarify transition commentary.These explanatory comments are helpful in conveying context about the transition between the old and new privilege management systems. Consider expanding on specific differences (e.g., old system checks rely on a hierarchical boundary, while the new system focuses on explicit action-subject permissions) to give future maintainers a clearer view of the underlying rationale.
frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersSection.tsx (1)
57-57
: Check usage alignment with newly introduced permission constants.Using
I={OrgPermissionGroupActions.Edit}
is consistent with the refactored group-specific permission. Make sure that other permission checks in different components (if any) are also updated fromOrgPermissionActions.Edit
toOrgPermissionGroupActions.Edit
for consistency.frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGroupRow.tsx (3)
36-68
: Streamline toggle logic for expansion and custom state.Currently, the row auto-expands when set to "Custom," but also provides a toggle for the user. If users switch away from Custom and then back again, the behavior could become confusing. Consider combining or centralizing this state logic to ensure a straightforward UI flow.
70-140
: Refactor permission setting to reduce duplication.Your switch statement uses repeated blocks assigning almost the same structure. To adhere to DRY principles, consider factoring out a helper function that returns the configuration object for each case (e.g.,
getPermissionConfigByType(permissionType)
), which you then pass tosetValue
.
142-207
: Ensure informative error handling in UI.When updates fail in the checkboxes (line 185), the notification simply says "Failed to update default role," which might be less clear for group-specific permissions. Consider providing a more contextual error message, such as "Failed to update group permissions" to aid troubleshooting.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (51)
backend/src/ee/services/group/group-service.ts
(12 hunks)backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts
(10 hunks)backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts
(9 hunks)backend/src/ee/services/permission/org-permission.ts
(5 hunks)backend/src/ee/services/permission/permission-fns.ts
(2 hunks)backend/src/ee/services/permission/project-permission.ts
(9 hunks)backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts
(8 hunks)backend/src/services/group-project/group-project-service.ts
(8 hunks)backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
(6 hunks)backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
(6 hunks)backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
(6 hunks)backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
(6 hunks)backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
(6 hunks)backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
(6 hunks)backend/src/services/identity-project/identity-project-service.ts
(8 hunks)backend/src/services/identity-token-auth/identity-token-auth-service.ts
(12 hunks)backend/src/services/identity-ua/identity-ua-service.ts
(14 hunks)backend/src/services/identity/identity-service.ts
(8 hunks)backend/src/services/org/org-service.ts
(3 hunks)backend/src/services/project-key/project-key-service.ts
(3 hunks)backend/src/services/project-membership/project-membership-service.ts
(9 hunks)frontend/src/context/OrgPermissionContext/index.tsx
(1 hunks)frontend/src/context/OrgPermissionContext/types.ts
(2 hunks)frontend/src/context/ProjectPermissionContext/index.tsx
(1 hunks)frontend/src/context/ProjectPermissionContext/types.ts
(1 hunks)frontend/src/context/index.tsx
(2 hunks)frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
(2 hunks)frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx
(2 hunks)frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx
(5 hunks)frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
(3 hunks)frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
(4 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx
(4 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/components/AddGroupMemberModal.tsx
(2 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupDetailsSection.tsx
(2 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersSection.tsx
(2 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx
(2 hunks)frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembershipRow.tsx
(2 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
(2 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
(2 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityClientSecrets.tsx
(2 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx
(3 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityTokenAuthTokensTable.tsx
(4 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityUniversalAuthClientSecretsTable.tsx
(3 hunks)frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper.tsx
(3 hunks)frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
(4 hunks)frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGroupRow.tsx
(1 hunks)frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionIdentityRow.tsx
(1 hunks)frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx
(2 hunks)frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
(1 hunks)frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx
(2 hunks)frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
(5 hunks)
🔇 Additional comments (157)
frontend/src/context/ProjectPermissionContext/index.tsx (1)
7-10
: New permission action exports addedThese new exports add more granular permission controls for projects by separating actions into specific categories (group, identity, member). This aligns with the "privilege management v2 transition" mentioned in the PR objectives.
frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx (3)
9-13
: Import updated to use more specific permission action typeReplacing generic permission actions with identity-specific ones improves permission clarity and granularity.
90-93
: Permission check updated to use identity-specific actionsThe permission check now uses
OrgPermissionIdentityActions.Create
instead of the previous generic permission, making the permission model more specific and maintainable.
149-149
: Component permission requirement updatedThe withPermission HOC now correctly uses identity-specific read permission, aligning with the new granular permission model.
frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx (2)
18-19
: Added new permission components for groups and identitiesThese new imports allow for more specific permission handling of groups and identities, which is consistent with the privilege management v2 transition.
164-173
: Added dedicated permission rows for identities and groupsReplacing generic permission options with dedicated components for identity and group permissions provides a more structured and granular approach to permission management.
frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx (1)
143-143
: Updated permission subject for user editingChanged the permission check from
Identity
toMember
subject, which more accurately reflects the resource being managed. This is a necessary correction for the permission model to work properly.frontend/src/pages/organization/UserDetailsByIDPage/components/UserDetailsSection.tsx (2)
85-85
: Correct subject type for membership editing permissions.The permission subject has been updated from
Identity
toMember
, which is more appropriate for this context since the component is handling membership details specifically.
199-199
: Permission subject properly aligned for resend invite functionality.The permission subject change from
Identity
toMember
ensures consistent permission checking throughout the component and properly reflects the action being performed on a membership.frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupDetailsSection.tsx (2)
7-7
: Import updated to use more specific group permission actions.Replaced generic
OrgPermissionActions
with the more specificOrgPermissionGroupActions
, which better aligns with the privilege management v2 transition.
25-25
: Updated permission check to use group-specific action.The permission check now uses
OrgPermissionGroupActions.Edit
instead of the genericOrgPermissionActions.Edit
, providing more granular control over group-related permissions.frontend/src/context/index.tsx (2)
4-9
: Added exports for specific organization permission action types.New exports for
OrgPermissionGroupActions
andOrgPermissionIdentityActions
enable more granular permission control throughout the application. This change supports the broader privilege management v2 transition.
12-21
: Added exports for specific project permission action types.New exports for
ProjectPermissionGroupActions
,ProjectPermissionIdentityActions
, andProjectPermissionMemberActions
improve the specificity of permission checks at the project level, consistent with the organization-level permission updates.frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx (2)
8-8
: Updated import to use more specific group permission actions.Replaced generic
OrgPermissionActions
with the more specificOrgPermissionGroupActions
, aligning with the privilege management v2 transition.
61-61
: Permission check updated to use group-specific action for creation.The permission check now uses
OrgPermissionGroupActions.Create
instead of the genericOrgPermissionActions.Create
, providing more granular control specifically for group creation actions.frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx (4)
35-35
: Updated permission import to use identity-specific actions.The code now imports
OrgPermissionIdentityActions
instead of genericOrgPermissionActions
, which aligns with the permission management v2 transition that uses more specific action sets for different entity types.
210-211
: Permission check using identity-specific action.Correctly updated to use
OrgPermissionIdentityActions.Edit
for checking identity editing permissions, providing more granular control over identity-related operations.
246-247
: Consistent permission check for edit dropdown item.Updated to use the new
OrgPermissionIdentityActions.Edit
permission action, maintaining consistency with other identity-related permission checks.
270-271
: Delete permission check using identity-specific action.Updated to use
OrgPermissionIdentityActions.Delete
instead of the generic permission action, ensuring appropriate permission checking for identity deletion.frontend/src/context/OrgPermissionContext/index.tsx (1)
3-8
: Expanded exports with entity-specific permission actions.The export statement has been restructured to include more granular permission action sets:
- Added
OrgPermissionGroupActions
for group-specific operations- Added
OrgPermissionIdentityActions
for identity-specific operationsThis change enhances the permission model by providing entity-specific action sets, which improves type safety and permission control granularity.
frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityTokenAuthTokensTable.tsx (4)
23-23
: Updated permission import to use identity-specific actions.The import has been updated to use
OrgPermissionIdentityActions
instead of genericOrgPermissionActions
, aligning with the new permission management structure.
82-82
: Permission check for adding tokens using identity-specific action.Updated the permission check for adding tokens to use
OrgPermissionIdentityActions.Edit
, which provides clearer intent about which specific permission is being checked.
147-148
: Permission check for editing tokens using identity-specific action.The token edit permission check now uses the more specific
OrgPermissionIdentityActions.Edit
, improving permission clarity.
172-173
: Permission check for revoking tokens using identity-specific action.The permission check for token revocation now uses
OrgPermissionIdentityActions.Edit
, maintaining consistent permission checking for all token management operations.frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/ViewIdentityContentWrapper.tsx (3)
13-13
: Updated permission import to use identity-specific actions.The import has been updated to use
OrgPermissionIdentityActions
instead of genericOrgPermissionActions
, consistent with the permission system v2 transition.
39-42
: Permission check for edit option using identity-specific action.The dropdown edit option now uses
OrgPermissionIdentityActions.Edit
for permission checking, providing more specific control over identity editing permissions.
53-56
: Permission check for delete option using identity-specific action.The dropdown delete option now uses
OrgPermissionIdentityActions.Delete
for permission checking, ensuring proper authorization for identity deletion operations.frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx (2)
6-6
: Correctly updated import to use identity-specific permission actionsThe change from
OrgPermissionActions
toOrgPermissionIdentityActions
aligns with the transition to more granular, identity-specific permission management.
50-50
: Permission check properly updated to use identity-specific actionThe permission check has been correctly updated from the generic
OrgPermissionActions.Edit
to the more specificOrgPermissionIdentityActions.Edit
, maintaining consistency with the updated import.frontend/src/pages/organization/IdentityDetailsByIDPage/components/ViewIdentityAuthModal/IdentityUniversalAuthClientSecretsTable.tsx (3)
23-23
: Correctly updated import to use identity-specific permission actionsThe change from
OrgPermissionActions
toOrgPermissionIdentityActions
properly aligns with the transition to more granular, identity-specific permission management.
71-71
: Permission check properly updated for Add Client Secret buttonThe permission check has been correctly updated from the generic
OrgPermissionActions.Edit
to the more specificOrgPermissionIdentityActions.Edit
, maintaining consistency with the updated import.
132-132
: Permission check properly updated for Delete Secret buttonThe permission check for the Delete Secret icon button has been correctly updated to use
OrgPermissionIdentityActions.Edit
for consistency with the updated permission model.frontend/src/context/ProjectPermissionContext/types.ts (4)
45-51
: New identity-specific permission actions enum addedThe addition of
ProjectPermissionIdentityActions
provides more granular control over identity-related permissions, including the specializedManagePrivileges
action for identity privilege management.
53-59
: New member-specific permission actions enum addedThe
ProjectPermissionMemberActions
enum properly mirrors the structure of other permission enums and includes the specializedManagePrivileges
action for member privilege management.
61-67
: New group-specific permission actions enum addedThe
ProjectPermissionGroupActions
enum follows the same pattern as the other new permission enums, providing consistent access control for group-related operations.
45-67
:✅ Verification successful
Verify that ProjectPermissionSet is updated elsewhere
The file defines new permission enums but doesn't update the
ProjectPermissionSet
type to use them. Ensure that theProjectPermissionSet
type is updated in a subsequent PR or elsewhere in this PR to properly utilize these new enum types.
🏁 Script executed:
#!/bin/bash # Description: Check if ProjectPermissionSet is updated elsewhere to use the new permission action enums # Find the ProjectPermissionSet definition in this PR rg "ProjectPermissionSet" --type ts # Look for usage of the new permission actions in ProjectPermissionSet echo "Searching for references to the new enums in relation to ProjectPermissionSet..." rg "ProjectPermissionIdentityActions|ProjectPermissionMemberActions|ProjectPermissionGroupActions" --type ts -A 5 -B 5Length of output: 126189
Verified – ProjectPermissionSet properly supports the new enums
After reviewing the changes and examining the codebase, all references to the new permission action enums are in use (e.g. in CASL schemas and permissions validations across both frontend and backend). The updates to ProjectPermissionSet are implicitly applied via its usage in files likeproject-permission.ts
,withProjectPermission.tsx
, and the role-modification utilities, confirming that the changes are in sync. No further modifications are needed for ProjectPermissionSet at this time.frontend/src/pages/organization/GroupDetailsByIDPage/components/AddGroupMemberModal.tsx (2)
23-23
: Correctly updated import to use group-specific permission actionsThe change from
OrgPermissionActions
toOrgPermissionGroupActions
is appropriate for the transition to more granular, group-specific permission management.
127-127
: Permission check properly updated to use group-specific actionThe permission check has been correctly updated from the generic
OrgPermissionActions.Edit
to the more specificOrgPermissionGroupActions.Edit
for the Assign button, maintaining consistency with the updated import.frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityClientSecrets.tsx (2)
7-7
: Updated import statement to use identity-specific permission actionsThe import has been changed from
OrgPermissionActions
toOrgPermissionIdentityActions
, which aligns with the privilege management v2 transition that provides more granular and entity-specific permission controls.
121-121
: Updated permission check to use identity-specific actionThe permission check now uses
OrgPermissionIdentityActions.Edit
instead of the more genericOrgPermissionActions.Edit
, providing better specificity and clarity around the required permission for editing identity client secrets.frontend/src/pages/organization/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx (2)
10-10
: Updated import statement to use identity-specific permission actionsThe import has been changed from
OrgPermissionActions
toOrgPermissionIdentityActions
, which aligns with the privilege management v2 transition that provides more granular permission controls.
135-135
: Updated permission check to use identity-specific actionThe permission check now uses
OrgPermissionIdentityActions.Read
instead of the more genericOrgPermissionActions.Read
, providing better specificity and clarity around the required permission for viewing identity details.frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsTable.tsx (3)
36-36
: Updated import statement to use group-specific permission actionsThe import has been changed from
OrgPermissionActions
toOrgPermissionGroupActions
, which aligns with the privilege management v2 transition that provides more granular permission controls specific to group operations.
244-244
: Updated permission checks for group editing to use group-specific actionsThe permission checks now use
OrgPermissionGroupActions.Edit
instead of the more genericOrgPermissionActions.Edit
, providing better specificity and clarity around the required permission for editing groups.Also applies to: 292-292, 318-318
342-342
: Updated permission check for group deletion to use group-specific actionThe permission check now uses
OrgPermissionGroupActions.Delete
instead of the more genericOrgPermissionActions.Delete
, providing better specificity and clarity around the required permission for deleting groups.frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityDetailsSection.tsx (3)
23-23
: Updated import statement to use identity-specific permission actionsThe import has been changed from
OrgPermissionActions
toOrgPermissionIdentityActions
, which aligns with the privilege management v2 transition that provides more granular permission controls specific to identity operations.
57-60
: Updated permission check for identity editing to use identity-specific actionThe permission check now uses
OrgPermissionIdentityActions.Edit
instead of the more genericOrgPermissionActions.Edit
, providing better specificity and clarity around the required permission for editing identity details.
81-84
: Updated permission check for identity deletion to use identity-specific actionThe permission check now uses
OrgPermissionIdentityActions.Delete
instead of the more genericOrgPermissionActions.Delete
, providing better specificity and clarity around the required permission for deleting an identity.backend/src/services/project-key/project-key-service.ts (3)
5-5
: Updated import to use more granular permission actionsThe import has been updated to use
ProjectPermissionMemberActions
instead of the genericProjectPermissionActions
, reflecting the transition to a more granular permission model that's specific to member actions.
43-43
: Refined permission check with member-specific actionPermission check is properly updated to use the more specific
ProjectPermissionMemberActions.Edit
instead of the generic permission action, providing better clarity on the exact permission being checked.
92-92
: Consistent permission check update for read operationSimilar to the edit permission, this read permission has been properly updated to use the more specific
ProjectPermissionMemberActions.Read
constant, maintaining consistency across the file.frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx (3)
7-13
: Expanded imports to support more granular permission actionsThe imports have been properly expanded to include the new permission action types
OrgPermissionGroupActions
andOrgPermissionIdentityActions
that will be used for more specific permission checks.
46-46
: Updated Groups tab permission to use group-specific actionThe permission check for the Groups tab now correctly uses the more specific
OrgPermissionGroupActions.Read
instead of the generic permission action.
52-55
: Updated Identities tab permission to use identity-specific actionThe permission check for the Identities tab now correctly uses the more specific
OrgPermissionIdentityActions.Read
action with the appropriate subject.backend/src/services/identity-token-auth/identity-token-auth-service.ts (4)
6-7
: Updated imports for the new permission systemThe imports have been properly updated to:
- Replace generic
OrgPermissionActions
with identity-specificOrgPermissionIdentityActions
- Add the new
validatePrivilegeChangeOperation
function which offers more granular permission validation
84-84
: Consistently updated all permission checks to use identity-specific actionsAll permission checks in the file have been systematically updated to use the more specific
OrgPermissionIdentityActions
instead of the genericOrgPermissionActions
, providing clear indications of the exact permissions needed for each operation.Also applies to: 157-157, 211-211, 238-238, 296-296, 381-381, 424-424, 492-492
248-253
: Enhanced permission validation with explicit action and subjectThe permission boundary validation has been updated to use the new
validatePrivilegeChangeOperation
function, which provides more granular validation by explicitly specifying the action (OrgPermissionIdentityActions.RevokeAuth
) and subject (OrgPermissionSubjects.Identity
).
306-311
: Consistently updated permission validation across all operationsAdditional instances of permission boundary validation have been updated to use the more specific
validatePrivilegeChangeOperation
function with appropriate actions, maintaining consistency throughout the file.Also applies to: 433-438
backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts (3)
8-9
: Updated imports for the new permission systemThe imports have been properly updated to:
- Replace generic
OrgPermissionActions
with identity-specificOrgPermissionIdentityActions
- Add the new
validatePrivilegeChangeOperation
function for enhanced permission validation
267-267
: Consistently updated all permission checks to use identity-specific actionsAll permission checks in the file have been systematically updated to use the more specific
OrgPermissionIdentityActions
instead of the genericOrgPermissionActions
, providing clearer indication of the exact permissions needed for each JWT auth operation.Also applies to: 370-370, 459-459, 501-501
511-516
: Enhanced permission validation with explicit action and subjectThe permission boundary validation has been updated to use the new
validatePrivilegeChangeOperation
function with explicit action (OrgPermissionIdentityActions.RevokeAuth
) and subject (OrgPermissionSubjects.Identity
) parameters, providing more precise permission control.frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembershipRow.tsx (2)
6-6
: Import updated to use more specific permission action typesThe change from
OrgPermissionActions
toOrgPermissionGroupActions
improves type specificity for group-related permission checks, aligning with the broader privilege management transition.
42-42
: Permission check updated to use group-specific actionProperly updated the permission check to use
OrgPermissionGroupActions.Edit
instead of the more genericOrgPermissionActions.Edit
, maintaining consistent permission handling throughout the application.backend/src/ee/services/group/group-service.ts (4)
16-17
: Imports updated for more granular permission handlingThe imports have been appropriately updated to use the more specific
OrgPermissionGroupActions
and the newvalidatePrivilegeChangeOperation
function, aligning with the privilege management v2 transition.
77-77
: Permission check updated to use group-specific actionUpdated from generic
OrgPermissionActions.Create
to the more specificOrgPermissionGroupActions.Create
for better permission control granularity.
91-96
: Enhanced permission validation with specific action and subject parametersThe
validatePermissionBoundary
function has been replaced withvalidatePrivilegeChangeOperation
, which now explicitly requires action and subject parameters, providing more granular control over permission boundaries.
148-148
: Permission checks consistently updated throughout the serviceAll permission checks in the group service have been consistently updated to use the more specific
OrgPermissionGroupActions
constants and the newvalidatePrivilegeChangeOperation
function, ensuring proper permission handling throughout the service.Also applies to: 169-174, 228-228, 255-255, 288-288, 323-323, 351-356, 399-399, 427-432
backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts (4)
11-17
: Updated imports for enhanced permission managementReplaced generic permission imports with more specific ones focused on member-related actions, and replaced
validatePermissionBoundary
withvalidatePrivilegeChangeOperation
for more granular permission validation.
70-70
: Permission check updated to use member-specific actionsPermission validation now uses the more specific
ProjectPermissionMemberActions.Edit
and the newvalidatePrivilegeChangeOperation
function with explicit action and subject parameters.Also applies to: 83-88
188-188
: Error message updated for consistencyUpdated error message from "Failed to update more privileged identity" to "Failed to update more privileged user," maintaining consistent terminology in the codebase.
166-166
: Consistent permission checks throughout the serviceAll permission checks in the service have been consistently updated to use the more specific
ProjectPermissionMemberActions
constants, maintaining proper permission handling throughout the service.Also applies to: 179-184, 261-261, 298-298, 325-325
backend/src/services/identity-azure-auth/identity-azure-auth-service.ts (3)
6-7
: Imports updated for identity-specific permission handlingUpdated imports to use the more specific
OrgPermissionIdentityActions
and added the newvalidatePrivilegeChangeOperation
function for enhanced permission validation.
146-146
: Permission checks updated to use identity-specific actionsAll permission checks have been consistently updated to use the more specific
OrgPermissionIdentityActions
constants, providing better granularity for identity-related permission handling.Also applies to: 224-224, 280-280, 306-306
315-320
: Enhanced validation for revoking identity authenticationReplaced
validatePermissionBoundary
withvalidatePrivilegeChangeOperation
, now requiring explicit action and subject parameters for more precise permission boundary validation when revoking Azure authentication.backend/src/ee/services/permission/permission-fns.ts (1)
56-72
: Ensure consistent return object shape between both checks.This function returns a hard-coded object
{ isValid: true, missingPermissions: [] }
if the actor has permission, and otherwise delegates tovalidatePermissionBoundary
. Confirm thatvalidatePermissionBoundary
uses the same object signature (i.e., includesisValid
andmissingPermissions
) to avoid unexpected issues. Also, adding unit tests for scenarios where the boundary check fails or partially fails would be beneficial for reliability.Do you want to see an example test suite snippet validating different boundary scenarios?
frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersSection.tsx (1)
7-7
: Confirm imports for new permission actions.Switching from
OrgPermissionActions
toOrgPermissionGroupActions
clarifies that actions pertain specifically to group management. Verify that any other references throughout the component or related files are similarly updated to avoid mismatched imports.frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGroupRow.tsx (1)
13-21
: Validate the permission actions array.Enumerating the group-specific actions here ensures clarity in your permission model. Just confirm that these labels and enumerations accurately match the definitions in the backend (e.g.,
OrgPermissionGroupActions
) so there is no mismatch.frontend/src/context/OrgPermissionContext/types.ts (3)
57-67
: New identity permission actions enhance granularityThe addition of
OrgPermissionIdentityActions
enum provides fine-grained control over identity management permissions. This is a good enhancement that allows for more precise permission control, particularly for sensitive operations like token management and authentication revocation.
69-77
: Group-specific permission actions improve access controlThe introduction of
OrgPermissionGroupActions
enum separates group management permissions from generic actions, which is a good practice for permission management. This provides better isolation between different types of resources.
93-93
: Updated permission sets align with new action typesThe changes to
OrgPermissionSet
properly integrate the new permission action types, maintaining type safety throughout the permission system. The modification ensures proper typing when checking permissions related to groups and identities.Also applies to: 101-101
backend/src/services/identity-ua/identity-ua-service.ts (3)
9-10
: Updated imports reflect permission system transitionThe import changes appropriately replace generic permission constants with identity-specific ones and add the new validation function. This is consistent with the overall transition of the privilege management system.
175-175
: Refined permission checks with identity-specific actionsPermission checks have been updated to use identity-specific actions rather than generic ones, providing better granularity in permission control. This change maintains the same behavior while making the permission model more precise.
Also applies to: 266-266, 335-335, 361-361, 416-416, 483-483, 541-541, 591-591
370-375
: Enhanced privilege validation with explicit action parametersThe replacement of
validatePermissionBoundary
withvalidatePrivilegeChangeOperation
adds explicit action and subject parameters, enabling more granular permission validation during privilege changes. This improves the specificity of permission checks and makes the code more maintainable.Also applies to: 425-430, 493-498, 550-555, 601-606
frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionIdentityRow.tsx (4)
13-23
: Well-defined permission actions with clear labelsThe permission actions are clearly defined with descriptive labels, making it easier for administrators to understand the implications of each permission. This improves usability of the permission management interface.
31-36
: Structured permission categories for intuitive UIThe permission categories (NoAccess, ReadOnly, FullAccess, Custom) provide a good balance between simplicity for common use cases and flexibility for advanced scenarios. This makes the permission UI both powerful and approachable.
72-149
: Comprehensive permission handling logicThe permission change handler implements a thorough approach to managing permission states. Each category (NoAccess, ReadOnly, FullAccess, Custom) properly sets all relevant permission flags, ensuring consistent state management.
184-210
: Accessible permission management UI with clear error feedbackThe permission checkboxes are well-implemented with proper error handling. When a user tries to modify permissions without edit rights, they receive a clear error notification rather than a silent failure.
backend/src/services/identity-project/identity-project-service.ts (3)
5-7
: Updated imports align with project-level permission changesThe imports properly reflect the transition to more specific permission actions for project identity management, maintaining consistency with the overall privilege management update.
65-65
: Updated permission checks with identity-specific actionsThe project-level permission checks now use
ProjectPermissionIdentityActions
instead of generic actions, improving the specificity of the permission model and maintaining consistency with the organization-level changes.Also applies to: 178-178, 283-283, 312-314, 347-347
93-98
: Permission boundary validation with explicit parametersThe transition to
validatePrivilegeChangeOperation
with explicit action and subject parameters enhances the granularity of permission validation during privilege changes, making the permission boundaries more precise.Also applies to: 194-199
backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts (6)
12-12
: Import changed from validatePermissionBoundary to validatePrivilegeChangeOperationThis change is part of the transition to a more granular permission model where permissions are validated with explicit action and subject parameters.
14-14
: Using more specific ProjectPermissionIdentityActions instead of generic ProjectPermissionActionsThis improves type safety by using identity-specific permission actions rather than generic ones, aligning with the new privilege management system.
67-69
: Permission check updated to use identity-specific actionsThe permission check now uses ProjectPermissionIdentityActions.Edit instead of a generic permission action, making the permission model more precise.
82-87
: Permission validation now uses more explicit parametersThe validatePrivilegeChangeOperation function now requires explicit action and subject parameters, which enhances type safety and clarity of the permission model.
173-178
: Consistent usage of new permission validation patternThe pattern of using validatePrivilegeChangeOperation with specific action and subject parameters is consistently applied throughout the service.
260-265
: Same validation pattern in deleteById methodThe validatePrivilegeChangeOperation function is consistently used here with the appropriate action and subject for deleting privileges.
backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts (3)
9-10
: Updated imports for the new permission modelThe imports have been updated to use OrgPermissionIdentityActions and add validatePrivilegeChangeOperation, aligning with the new privilege management system.
223-223
: Using identity-specific permission actionsThe permission check now uses OrgPermissionIdentityActions.Create for more precise permission control when attaching OIDC auth.
431-436
: Enhanced permission validation for revokeOidcAuthThe validatePrivilegeChangeOperation function now takes explicit action and subject parameters, enhancing the specificity of the permission validation when revoking OIDC authentication.
frontend/src/pages/organization/GroupDetailsByIDPage/components/GroupMembersSection/GroupMembersTable.tsx (2)
27-27
: Updated import to use group-specific permission actionsThe import has been changed to use OrgPermissionGroupActions instead of generic OrgPermissionActions, aligning with the backend changes to the permission model.
180-180
: Permission check now uses group-specific actionsThe OrgPermissionCan component now checks for OrgPermissionGroupActions.Edit permission instead of a generic edit permission, ensuring consistency with the backend permission model.
backend/src/services/identity/identity-service.ts (5)
5-6
: Updated imports for the new permission modelThe imports have been updated to use OrgPermissionIdentityActions and add validatePrivilegeChangeOperation, aligning with the new privilege management system.
53-53
: Using identity-specific permission actionsThe permission check now uses OrgPermissionIdentityActions.Create for more precise permission control when creating identities.
60-65
: Enhanced permission validation for createIdentityThe validatePrivilegeChangeOperation function now takes explicit action and subject parameters, enhancing the specificity of the permission validation when creating identities.
141-146
: Consistent use of new permission validation in updateIdentityThe appliedRolePermissionBoundary validation now uses validatePrivilegeChangeOperation with specific action and subject parameters, consistent with the pattern used throughout the codebase.
217-218
: Simplified permission check for deleteIdentityThe code has been simplified by removing what appears to have been a redundant permission check, while still ensuring proper permission validation before deleting an identity.
frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts (4)
8-9
: LGTM: Importing new permission action typesThese imports align with the overall PR goal of transitioning to a more granular permission model by providing specific action types for groups and identities.
40-53
: New identity permission schema looks goodThis new schema provides granular control over identity-related permissions, which is a significant improvement over the previous generic permission approach. The schema properly includes specific actions like ManagePrivileges, RevokeAuth, and various token operations.
54-64
: New group permission schema looks goodThe schema correctly implements granular control for group-related permissions, with appropriate actions like ManagePrivileges, AddMembers, and RemoveMembers that are specific to group management.
98-98
: Properly updated form schema to use new permission schemasThe form schema now correctly uses the more specific permission schemas for groups and identities instead of the previous generic schema, completing the transition to the granular permission model.
Also applies to: 108-108
backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (4)
12-18
: Good implementation of updated permission importsReplacing the generic permission imports with the more specific identity-focused ones and adding the new validation function aligns well with the privilege management v2 transition.
79-82
: Updated permission check to use identity-specific actionsCorrectly changed from generic ProjectPermissionActions to ProjectPermissionIdentityActions for more precise permission control.
96-101
: Good implementation of the new privilege validation approachThe new validatePrivilegeChangeOperation function provides more granular control by explicitly specifying the action and subject, which is an improvement over the previous validatePermissionBoundary function.
172-175
: Consistent application of new permission system throughout the serviceAll permission checks and boundary validations have been updated consistently throughout the different methods of the service, ensuring a complete transition to the new permission model.
Also applies to: 189-194, 281-284, 294-299, 349-352, 393-396
backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts (3)
8-9
: Good adoption of new permission importsCorrectly imported the new identity-specific permission actions and validation function, supporting the transition to a more granular permission model.
252-252
: Consistent updates to permission checksAll permission checks throughout the service have been updated from generic OrgPermissionActions to identity-specific OrgPermissionIdentityActions, maintaining consistency with the new permission model.
Also applies to: 343-343, 437-437, 481-481
490-495
: Effective implementation of new privilege validationThe service now correctly uses validatePrivilegeChangeOperation with explicit action and subject parameters, providing more precise permission control for the RevokeAuth operation.
backend/src/ee/services/permission/project-permission.ts (5)
37-60
: Well-structured new permission action enumsThese new enums provide a clear separation of concerns for different entity types (identity, member, group), with appropriate actions for each. The ManagePrivileges action is particularly important for the privilege management v2 transition.
168-170
: Good update to ProjectPermissionSet typeThe ProjectPermissionSet type has been properly updated to use the new entity-specific permission actions, ensuring type safety throughout the permission system.
Also applies to: 180-180
307-317
: Updated schema definitions for new permission modelThe GeneralPermissionSchema and ProjectPermissionV2Schema have been properly updated to use the new entity-specific permission actions, ensuring consistent validation throughout the system.
Also applies to: 527-528
578-610
: Comprehensive updates to admin permission rulesThe buildAdminPermissionRules function now correctly grants all the entity-specific permissions, including the new ManagePrivileges action, ensuring admins have complete control.
711-713
: Appropriate updates to member and viewer permission rulesThe permission building functions for members and viewers have been updated to use the entity-specific permission actions, with appropriate restrictions based on role level.
Also applies to: 736-743, 852-858
backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts (6)
6-7
: Permission system imports updated for new identity-specific actionsThe code now imports more specific permission constants and validation functions that align with the new privilege management system. The
OrgPermissionIdentityActions
provides fine-grained control over identity-related operations, andvalidatePrivilegeChangeOperation
supports the new permission validation approach.
187-187
: Updated permission check with identity-specific actionPermission check has been updated to use the more specific
OrgPermissionIdentityActions.Create
constant instead of the generic permission action, improving the granularity of permission control for identity operations.
267-267
: Updated permission check for identity editingThe permission check now uses the identity-specific
OrgPermissionIdentityActions.Edit
action, which is part of the permission system transition to more granular controls.
325-325
: Updated permission check for identity readingPermission verification now uses the identity-specific
OrgPermissionIdentityActions.Read
action instead of the generic permission action, consistent with the new permission model.
352-352
: Permission check updated for identity editing consistencyThe permission check is now using the identity-specific action
OrgPermissionIdentityActions.Edit
, maintaining consistency with the updated permission model throughout the service.
361-366
: Enhanced privilege validation with explicit action and subject parametersThe permission boundary validation has been replaced with
validatePrivilegeChangeOperation
, which takes explicit action (OrgPermissionIdentityActions.RevokeAuth
) and subject parameters for more precise permission checking. This provides clearer intent and better type safety.frontend/src/pages/organization/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx (4)
21-21
: Updated permission imports for group-specific actionsThe import statement now brings in
OrgPermissionGroupActions
instead of the genericOrgPermissionActions
, aligning the frontend with the backend's new permission model for greater specificity.
96-99
: Updated permission check for group editingThe
OrgPermissionCan
component now uses the group-specificOrgPermissionGroupActions.Edit
action, which provides more precise permission control for group operations in the UI.
119-122
: Updated permission check for group deletionPermission check for group deletion now uses the group-specific
OrgPermissionGroupActions.Delete
action instead of the generic permission action, maintaining consistency with the backend permission model.
188-188
: Updated permission check for group readingThe
OrgPermissionCan
component now usesOrgPermissionGroupActions.Read
for permission verification, completing the transition to group-specific permission actions throughout the component.backend/src/services/org/org-service.ts (4)
22-26
: Updated permission imports to include group-specific actionsThe import statement now includes
OrgPermissionGroupActions
alongside the regularOrgPermissionActions
, enabling more granular permission control in the organization service.
28-28
: Updated project permission import for member-specific actionsThe import has been updated to use
ProjectPermissionMemberActions
instead of the genericProjectPermissionActions
, continuing the pattern of more specific permission controls throughout the application.
190-190
: Group-specific permission check for reading groupsThe permission check now uses
OrgPermissionGroupActions.Read
instead of the genericOrgPermissionActions.Read
, providing consistent permission handling for group operations.
852-853
: Updated permission check for member creation in projectsThe permission check now uses
ProjectPermissionMemberActions.Create
instead of the generic permission action, completing the transition to specific permission actions for project memberships.backend/src/ee/services/permission/org-permission.ts (8)
43-53
: Added new enum for identity-specific permission actionsIntroduced
OrgPermissionIdentityActions
enum that defines fine-grained permissions for identity management including reading, creating, editing, deleting, managing privileges, and handling authentication and tokens.
55-63
: Added new enum for group-specific permission actionsIntroduced
OrgPermissionGroupActions
enum that provides granular control over group operations like reading, creating, editing, deleting, and managing members and privileges.
100-100
: Updated permission set type for group actionsThe
OrgPermissionSet
type now uses the more specificOrgPermissionGroupActions
for group subjects instead of generic permission actions.
103-103
: Updated permission set type for identity actionsThe
OrgPermissionSet
type now uses the identity-specificOrgPermissionIdentityActions
for identity subjects, enhancing type safety and clarity.
269-275
: Updated admin permissions for group operationsThe
buildAdminPermission
function now assigns the more specific group operation permissions like create, edit, delete, and member management, providing clear and precise permission definitions.
282-290
: Updated admin permissions for identity operationsThe
buildAdminPermission
function now grants admins specific identity permissions including the ability to read, create, edit, delete identities, and manage their privileges and authentication methods.
335-335
: Updated member permissions for reading groupsThe
buildMemberPermission
function now uses the specificOrgPermissionGroupActions.Read
permission for reading groups, maintaining consistency with the updated permission model.
346-349
: Updated member permissions for identity operationsRegular members now receive specific identity-related permissions using the new
OrgPermissionIdentityActions
enum, providing appropriate access to identity management features.frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx (3)
63-85
: New schema definitions enhance permission granularityThe addition of specific policy action schemas (
MemberPolicyActionSchema
,IdentityPolicyActionSchema
, andGroupPolicyActionSchema
) provides better type safety and clarity for permission actions on different subjects compared to the previous general schema approach.
168-175
: Schema updates in form validation improve type safetyReplacing the generic
GeneralPolicyActionSchema
with the specific policy schemas for Identity, Member, and Groups ensures proper type checking and validation for these permission subjects.
418-475
: Enhanced specific permission handling for subjectsThe implementation of specific handling for different permission subjects (Member, Identity, Groups) with their corresponding action constants improves code clarity and maintainability. Each subject now has its own dedicated section with appropriate action constants.
backend/src/services/identity-aws-auth/identity-aws-auth-service.ts (4)
8-9
: Updated imports for more specific permission handlingThe imports now utilize more specific permission action types (
OrgPermissionIdentityActions
) and a more granular validation function (validatePrivilegeChangeOperation
), aligning with the privilege management v2 transition.
174-174
: Identity-specific permission check for creationUsing
OrgPermissionIdentityActions.Create
instead of a generic permission action improves clarity and specificity of the permission check.
253-253
: Identity-specific permission checks for various operationsReplacing generic permission actions with specific
OrgPermissionIdentityActions
for Edit and Read operations provides better clarity about the required permissions for each operation.Also applies to: 307-307, 332-332
342-347
: Enhanced privilege validation with explicit parametersThe new
validatePrivilegeChangeOperation
function provides more granular validation by explicitly specifying the action and subject being validated, improving security and maintainability.backend/src/services/project-membership/project-membership-service.ts (3)
7-9
: Updated imports for project member permission handlingImporting the specific
ProjectPermissionMemberActions
and the enhanced validation functionvalidatePrivilegeChangeOperation
aligns with the privilege management v2 transition.
89-89
: Member-specific permission checks throughout the serviceAll permission checks now use
ProjectPermissionMemberActions
specific constants instead of generic actions, providing clearer intent and better type safety for member-related operations.Also applies to: 133-133, 156-156, 183-183, 264-264, 369-369, 405-405
277-282
: Granular privilege validation with explicit parametersThe
validatePrivilegeChangeOperation
function now explicitly receives the action and subject being validated, which enhances the security model by ensuring proper privilege validation.backend/src/services/group-project/group-project-service.ts (3)
5-7
: Updated imports for group permission handlingImporting the specific
ProjectPermissionGroupActions
and the enhanced validation functionvalidatePrivilegeChangeOperation
aligns with the privilege management v2 transition.
81-81
: Group-specific permission checks for operationsPermission checks throughout the service now use
ProjectPermissionGroupActions
specific constants instead of generic actions, providing clearer intent and better type safety for group-related operations.Also applies to: 264-264, 373-373, 418-418, 446-446
105-110
: Enhanced privilege validation for group operationsThe
validatePrivilegeChangeOperation
function is now used with explicit group-specific action and subject parameters, which improves security and clarity in privilege validation for group management.Also applies to: 277-282
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
backend/src/services/org/org-service.ts (1)
877-895
: New privilege boundary checks.
These checks prevent inviting users to roles beyond the inviter's own privileges. Consider adding or extending tests to confirm the error is thrown for insufficient roles. If performance becomes a concern, batching these checks could be considered.Would you like to add a test case verifying this boundary logic? I can draft a sample if needed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
backend/src/services/org/org-service.ts
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Run integration test
- GitHub Check: Check Frontend Type and Lint check
- GitHub Check: Check TS and Lint
🔇 Additional comments (4)
backend/src/services/org/org-service.ts (4)
22-26
: Imports for group-level org permissions look consistent.
No issues noted. This aligns with the new granularity for group actions.
191-191
: UsingOrgPermissionGroupActions.Read
enforces more precise permission checks.
This refined approach to group-level authorization enhances clarity.
853-854
: Swapping toProjectPermissionMemberActions.Create
properly scopes member creation permissions.
No functional concerns—this ensures correct access control for project membership.
29-29
:❓ Verification inconclusive
Validate full transition to
ProjectPermissionMemberActions
.
Ensure any lingering references to the olderProjectPermissionActions.Create
do not cause discrepancies.Use the following script to confirm there are no remaining references to
ProjectPermissionActions.Create
:
🏁 Script executed:
#!/bin/bash # Description: Find references to ProjectPermissionActions.Create in the codebase rg "ProjectPermissionActions\.Create" -A 5Length of output: 75504
Action Required: Verify and Address Legacy Permission References
The update in
backend/src/services/org/org-service.ts
correctly imports and usesProjectPermissionMemberActions
. However, the grep search for"ProjectPermissionActions.Create"
returned numerous matches across the codebase (both in frontend components and various backend service files). Please:
- Confirm whether these remaining legacy references are intentional (as part of a phased migration) or need to be updated for a full transition.
- Review the impacted files (e.g., components in
frontend/src/pages/…
and services inbackend/src/services/…
) to ensure that using the oldProjectPermissionActions.Create
won’t cause discrepancies.It’s important to decide if the transition to
ProjectPermissionMemberActions
should be extended to these areas for consistency and correctness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/internals/permissions.mdx (2)
47-47
: Clarify Identity Permissions in Project-Level TableIn the project permissions table, the
identity
subject now shows onlymanage-privileges
in addition to the standard actions. The overall permission model (per the PR objectives and broader changes) suggests that identity may require additional actions (such asrevoke-auth
,create-token
,delete-token
, andget-token
). If these extra actions are intended only for organization-level permissions, please clarify the rationale here to avoid confusion.
67-84
: Verify Organization Permissions Table UpdatesThe organization permissions table has been updated to include several new actions:
- For
groups
: the actions now includemanage-privileges
, as well asadd-members
andremove-members
.- For
identity
: the row now lists an expanded set of actions includingmanage-privileges
,revoke-auth
,create-token
,delete-token
, andget-token
.- Additionally, note that the
workspace
andkms
subjects have different permissions compared to the project scope.Please confirm that these changes are consistent with the overall privilege management v2 transition and that any differences between project-level and organization-level permissions are well documented.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/integrations/platforms/kubernetes/infisical-dynamic-secret-crd.mdx
(1 hunks)docs/internals/permissions.mdx
(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/integrations/platforms/kubernetes/infisical-dynamic-secret-crd.mdx
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Check TS and Lint
- GitHub Check: Run integration test
- GitHub Check: Check Frontend Type and Lint check
🔇 Additional comments (1)
docs/internals/permissions.mdx (1)
29-30
: Add "manage-privileges" Action to Project SubjectsThe updated rows for both the
member
andgroups
subjects now include the newmanage-privileges
action, which aligns with the intended enhancements for privilege management at the project level. Please verify that the inclusion of this action is scoped appropriately for projects.
…ment-v2-transition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 7
🔭 Outside diff range comments (10)
cli/packages/gateway/relay.go (1)
131-132
: 🛠️ Refactor suggestionCode duplication in CA certificate pool creation.
This code creates and initializes a certificate pool, but it's duplicated later at lines 149-150 within the
isTlsEnabled
condition block. Consider removing this first instance or consolidating the logic.-caCertPool := x509.NewCertPool() -caCertPool.AppendCertsFromPEM([]byte(g.Config.tlsCa))backend/src/services/project/project-types.ts (1)
80-87
: 💡 Verification agent❓ Verification inconclusive
Consider validating slug uniqueness.
When implementing the slug update functionality, ensure that the backend validates the uniqueness of the new slug within the organization to prevent conflicts.
🏁 Script executed:
#!/bin/bash # Check if the project service has slug uniqueness validation rg -A 10 "updateProject" backend/src/services/project/project-service.ts | grep -i "slug"Length of output: 87
Action Required: Implement and Enforce Slug Uniqueness Validation
After reviewing the
backend/src/services/project/project-types.ts
interface (lines 80–87) and checking the corresponding implementation inbackend/src/services/project/project-service.ts
(via the initial and extended grep queries), there is no evidence that the new slug is being verified for uniqueness within the organization. This leaves room for potential conflicts when updating a project’s slug.Recommendations:
- Add a uniqueness check: Before completing the slug update in the
updateProject
function, query the database (or appropriate datastore) to confirm that the new slug does not already exist for any project within the same organization.- Conflict resolution: Define clear behavior (e.g., rejecting the update with an error or generating an alternative unique slug) if a duplicate is found.
frontend/src/hooks/api/reactQuery.tsx (1)
73-76
:⚠️ Potential issueRemove duplicated and incomplete code block.
There's an incomplete and duplicated if statement for
PermissionBoundaryError
that appears to be leftover code.- if (serverResponse?.error === ApiErrorTypes.PermissionBoundaryError) { - ); - return; - }backend/src/services/identity/identity-service.ts (4)
189-196
:⚠️ Potential issueFix duplicated code in getIdentityById method.
There appear to be multiple instances of the same code for permission checks. The method seems to have been duplicated during the editing process, resulting in inconsistent code.
Check the entire method and ensure there's only one implementation of the permission check and return statement.
206-225
:⚠️ Potential issueFix duplicated code in deleteIdentity method.
Similar to the getIdentityById method, there's duplication in the permission check code. Lines 207-216 appear to be an incomplete version of the same functionality as lines 214-224.
Resolve the duplication by ensuring there's only one implementation of the permission check.
227-257
:⚠️ Potential issueFix duplicated code in listOrgIdentities method.
The method appears to have been duplicated during the editing process, with two sets of parameter declarations and implementations.
Ensure there's only one implementation of the method with the correct parameters and implementation.
259-280
:⚠️ Potential issueFix duplicated code in listProjectIdentitiesByIdentityId method.
There's duplication in the permission check code, with lines 265-268 being a partial duplicate of lines 272-276.
Resolve the duplication by ensuring there's only one implementation of the permission check.
cli/packages/gateway/gateway.go (1)
333-369
: 🛠️ Refactor suggestionRefactored
registerRelayIsActive
to accept an address and dial QUIC.This approach attempts verifying connectivity via a QUIC handshake. The logic is generally sound. Noting the duplication of
case <-ticker.C:
blocks: the first block (lines 342–345) is returning immediately, overshadowing the second block’s logic (lines 347+). Consider consolidating or removing the first block to avoid confusion.- case <-ticker.C: - log.Debug().Msg("Performing relay connection health check") - log.Info().Msg("Stopping relay connection health check") - returnfrontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx (2)
87-100
:⚠️ Potential issueDuplicate schema definition
There's a duplicate definition of SecretRollbackPolicyActionSchema and GroupPolicyActionSchema in the file. The definition here overlaps with the one at lines 101-104 and 93-99 respectively.
Remove these duplicate definitions to prevent confusion and potential bugs:
-const SecretRollbackPolicyActionSchema = z.object({ - read: z.boolean().optional(), - create: z.boolean().optional() - [ProjectPermissionIdentityActions.ManagePrivileges]: z.boolean().optional() -}); - -const GroupPolicyActionSchema = z.object({ - [ProjectPermissionGroupActions.Read]: z.boolean().optional(), - [ProjectPermissionGroupActions.Create]: z.boolean().optional(), - [ProjectPermissionGroupActions.Edit]: z.boolean().optional(), - [ProjectPermissionGroupActions.Delete]: z.boolean().optional(), - [ProjectPermissionGroupActions.ManagePrivileges]: z.boolean().optional() -});
720-748
:⚠️ Potential issueDuplicate permission object definitions
These section definitions for Member, Identity, and Groups in PROJECT_PERMISSION_OBJECT are duplicates of the ones defined earlier in the file (lines 654-682).
Remove these duplicate definitions to prevent confusion and potential bugs:
- [ProjectPermissionSub.Member]: { - title: "User Management", - actions: [ - { label: "Read", value: ProjectPermissionMemberActions.Read }, - { label: "Add", value: ProjectPermissionMemberActions.Create }, - { label: "Modify", value: ProjectPermissionMemberActions.Edit }, - { label: "Remove", value: ProjectPermissionMemberActions.Delete }, - { label: "Manage Privileges", value: ProjectPermissionMemberActions.ManagePrivileges } - ] - }, - [ProjectPermissionSub.Identity]: { - title: "Machine Identity Management", - actions: [ - { label: "Read", value: ProjectPermissionIdentityActions.Read }, - { label: "Add", value: ProjectPermissionIdentityActions.Create }, - { label: "Modify", value: ProjectPermissionIdentityActions.Edit }, - { label: "Remove", value: ProjectPermissionIdentityActions.Delete }, - { label: "Manage Privileges", value: ProjectPermissionIdentityActions.ManagePrivileges } - ] - }, - [ProjectPermissionSub.Groups]: { - title: "Group Management", - actions: [ - { label: "Read", value: ProjectPermissionGroupActions.Read }, - { label: "Create", value: ProjectPermissionGroupActions.Create }, - { label: "Modify", value: ProjectPermissionGroupActions.Edit }, - { label: "Remove", value: ProjectPermissionGroupActions.Delete }, - { label: "Manage Privileges", value: ProjectPermissionGroupActions.ManagePrivileges } - ] - },
🧹 Nitpick comments (51)
frontend/src/components/v2/Blur/Blur.tsx (3)
10-22
: Consider enhancing keyboard accessibility.The component has good basic accessibility with
tabIndex={0}
androle="button"
, but lacks keyboard event handlers for Enter/Space key presses that would make it fully accessible. Also, consider adding anaria-label
to better describe the content for screen readers.<div className={twMerge("flex w-80 flex-grow items-center py-1 pl-4 pr-2", className)} tabIndex={0} role="button" + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + // Handle interaction, same as click handler + } + }} + aria-label={tooltipText || "Blurred sensitive content"} >
10-22
: Missing interactive functionality.The component displays blurred content, but doesn't provide any way to reveal or interact with it. If this component is meant to show/hide sensitive information, consider adding toggle functionality for the blur effect.
export const Blur = ({ className, tooltipText }: IProps) => { + const [isBlurred, setIsBlurred] = useState(true); + + const toggleBlur = () => { + setIsBlurred(!isBlurred); + }; return ( <Tooltip content={tooltipText} isDisabled={!tooltipText}> <div className={twMerge("flex w-80 flex-grow items-center py-1 pl-4 pr-2", className)} tabIndex={0} role="button" + onClick={toggleBlur} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + toggleBlur(); + } + }} > - <span className="blur">********</span> + <span className={isBlurred ? "blur" : ""}>********</span> </div> </Tooltip> ); };
1-22
: Add documentation for component usage.Consider adding JSDoc comments to document the purpose and usage of this component, especially since it appears to be related to displaying sensitive information in a UI.
+ /** + * Blur Component + * + * A component that displays blurred content (like passwords or sensitive information) + * with an optional tooltip. Used in contexts where sensitive information needs to be + * visually obscured but still represented in the UI. + */ interface IProps { className?: string; tooltipText?: string; }frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/MinimizedOrgSidebar.tsx (1)
423-455
: Consider simplifying the conditional rendering logicThe current implementation uses conditional rendering inside the map function, which makes the code more complex and harder to follow.
Consider filtering the options array before mapping to simplify the code:
- {INFISICAL_SUPPORT_OPTIONS.map(([icon, text, url]) => { - if (url === "server-admins" && isInfisicalCloud()) { - return null; - } - return ( + {INFISICAL_SUPPORT_OPTIONS.filter(([, , url]) => + !(url === "server-admins" && isInfisicalCloud()) + ).map(([icon, text, url]) => ( <DropdownMenuItem key={url as string}> {url === "server-admins" ? ( <button type="button" onClick={() => setShowAdminsModal(true)} className="flex w-full items-center rounded-md font-normal text-mineshaft-300 duration-200" > <div className="relative flex w-full cursor-pointer select-none items-center justify-start rounded-md"> {icon} <div className="text-sm">{text}</div> </div> </button> ) : ( <a target="_blank" rel="noopener noreferrer" href={String(url)} className="flex w-full items-center rounded-md font-normal text-mineshaft-300 duration-200" > <div className="relative flex w-full cursor-pointer select-none items-center justify-start rounded-md"> {icon} <div className="text-sm">{text}</div> </div> </a> )} </DropdownMenuItem> - ); - })} + ))}company/handbook/meetings.mdx (2)
15-15
: Typographical Suggestion: Use an En Dash for RangesIn the sentence on line 15, consider replacing the hyphen in "1-2 days" with an en dash for better typographical correctness. For example:
- if you are working on something that takes longer than 1-2 days, + if you are working on something that takes longer than 1–2 days,🧰 Tools
🪛 LanguageTool
[typographical] ~15-~15: If specifying a range, consider using an en dash instead of a hyphen.
Context: ...ing on something that takes longer than 1-2 days, please add an estimated completio...(HYPHEN_TO_EN)
19-20
: Stylistic Improvement: Rephrase Informal LanguageTo enhance the professional tone, consider rewording the phrase "but feel free to post those in Slack too." A suggestion might be:
- (but feel free to post those in Slack too). + (but you may also post them in Slack).🧰 Tools
🪛 LanguageTool
[style] ~19-~19: The phrase ‘feel free to’ is used quite frequently. Consider using a less frequent alternative to set your writing apart from others and make it sound more professional.
Context: ...pics in front of the whole company (but feel free to post those in Slack too).(FEEL_FREE_TO_STYLE_ME)
frontend/src/pages/admin/SignUpPage/SignUpPage.tsx (1)
80-80
: Simplified error message reduces user context.The error message has been simplified to a generic "Failed to create admin" which might not provide enough context for users to understand what went wrong during the sign-up process.
Consider providing more specific error messages based on the actual error that occurred:
- text: "Failed to create admin" + text: `Failed to create admin: ${err?.message || "Please try again later"}`cli/packages/gateway/relay.go (2)
88-90
: Fix grammatical error in error message.The error message has a small grammatical issue that should be corrected.
- return nil, fmt.Errorf("Failed to read load server tls key pair: %w", err) + return nil, fmt.Errorf("Failed to load server TLS key pair: %w", err)
1-188
: Overall code structure needs improvement.The code has several structural issues:
- Redundant certificate pool creation (lines 131-132 and 149-150)
- Nested identical conditions (line 137 and 148)
- Disconnected code fragments (lines 158-159)
- Potential missing null checks before using
g.Config.tlsCa
Consider a comprehensive refactoring of the TLS handling logic to make it more robust and maintainable.
cli/packages/gateway/systemd.go (1)
72-75
: Consider using cmd.Output() for error detailsWhile the current implementation works, using
reloadCmd.Output()
instead ofreloadCmd.Run()
would capture command output in case of failure, providing more detailed error information.-reloadCmd := exec.Command("systemctl", "daemon-reload") -if err := reloadCmd.Run(); err != nil { +reloadCmd := exec.Command("systemctl", "daemon-reload") +if output, err := reloadCmd.CombinedOutput(); err != nil { - return fmt.Errorf("failed to reload systemd: %v", err) + return fmt.Errorf("failed to reload systemd: %v, output: %s", err, output) }frontend/src/pages/auth/SignUpSsoPage/components/UserInfoSSOStep/UserInfoSSOStep.tsx (1)
206-208
: Simplified navigation flowThe navigation implementation properly replaces the previous step-based approach. This change eliminates the need for the
DownloadBackupPDFStep
component, streamlining the signup process.One suggestion to consider - add a comment explaining why the route is cast with
as const
to help future developers understand the typing necessity.frontend/src/pages/auth/PasswordResetPage/components/InputBackupKeyStep.tsx (1)
19-86
: Good implementation of backup key input form.The component is well-structured and follows React best practices. It properly handles form validation, error states, and the decryption process.
One minor note: there is a commented line
// setStep(3);
on line 36 that should be removed if it's no longer needed..github/workflows/check-api-for-breaking-changes.yml (1)
102-103
: More resilient cleanup processUsing
|| true
prevents the workflow from failing during cleanup if containers are already stopped or removed, ensuring the workflow completes properly even if cleanup operations encounter non-critical issues.However, there's a missing newline at the end of the file according to YAMLlint.
docker compose -f "docker-compose.dev.yml" down docker stop infisical-api || true -docker rm infisical-api || true +docker rm infisical-api || true +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 103-103: no new line character at the end of file
(new-line-at-end-of-file)
backend/src/lib/casl/boundary.test.ts (1)
6-213
: Comprehensive boundary checksThe variety of test cases (equal, less, or more privilege, disjoint sets, and inverted rules) thoroughly covers real-world scenarios.
You might consider adding an extra scenario for null or undefined conditions to confirm defensive handling in edge cases.
backend/src/services/secret-import/secret-import-fns.ts (3)
6-6
: Use descriptive naming or a constant grouping.This import adds a mask constant for hidden secret values. Consider grouping constants in a dedicated constants file or naming them in a more descriptive manner to improve discoverability and maintainability.
168-168
: Consider defaultingviewSecretValue
.If there's a common preference (e.g., default to
false
for better security), you could makeviewSecretValue
optional and default it in the function signature to enhance safety.
185-188
: Introduce an additional interface or type alias for the extended secret fields.These newly introduced fields (
secretValueHidden
,secretTags
, etc.) expand the typical secret schema. Consider defining a separate type or interface that extendsTSecretsV2
for improved clarity and reusability.backend/src/lib/casl/boundary.ts (2)
20-27
: Avoid potential confusion in utility functions.
getPermissionSetID
,invertTheOperation
, andformatConditionOperator
are concise. However, grouping them in autils
section or adding brief docstrings can help new contributors quickly understand their purpose.
28-138
: Thoroughly test edge cases inisOperatorsASubset()
.This function checks condition subsets (EQ, NEQ, IN, GLOB). Carefully verify edge cases like:
- Glob patterns overlapping with specific equality conditions.
- Large arrays in
$IN
.- Inverted matches.
Enhance test coverage with these scenarios to prevent subtle permission misconfigurations.
backend/src/server/routes/v1/project-router.ts (1)
338-340
: Include fallback handling for slug updates.When updating the slug for an existing project, ensure the code properly handles any references or dependencies that rely on the current slug. Consider migrations or explicit conflict resolution if the slug is already in use.
backend/src/services/webhook/webhook-types.ts (1)
33-38
: Ensure naming consistency and clarity for event constants.
TheWebhookEvents
enum uses a dotted syntax (e.g.,secrets.modified
) for some events and shorter strings (e.g.,test
) for others. Confirm that this style is intentional across the codebase, and consider standardizing event keys for easier maintenance.frontend/src/pages/auth/PasswordResetPage/components/EnterPasswordStep.tsx (4)
19-31
: Validate password form schema constraints.
The Zod schema is minimal—onlypassword
is strictly typed as a string. For completeness, consider defining more explicit constraints forpassword
within the Zod schema itself (e.g., minimum length). This may help unify the logic rather than splitting them between the form schema andpasswordCheck
.
45-99
: Optimize side effects withinhandlePasswordCheck
.
Each setter call (setValue(...)
) triggers a rerender in React Hook Form, potentially leading to performance bottlenecks. Consider batching updates or returning a combined object frompasswordCheck
to set multiple fields at once.
100-167
: Avoid storing plain text password in logs.
Ensure that any errors or debug logs inside this block do not unintentionally includedata.password
. It is good practice to anonymize or omit sensitive values.
169-326
: Improve user feedback on password validity.
The UI for password checks is robust, but it might be beneficial to highlight any failing criteria in real-time rather than waiting for form submission. This can be done by showing messages conditionally as the user types.backend/src/ee/routes/v2/identity-project-additional-privilege-router.ts (1)
34-36
: Refine error messages.
.refine(checkForInvalidPermissionCombination)
presumably throws a generic error message when combos are invalid. Provide a user-friendly or descriptive error that highlights the specific clash..refine(checkForInvalidPermissionCombination, { message: "Invalid permission combination detected. Please verify your request." })Also applies to: 100-101
backend/src/services/secret/secret-version-dal.ts (1)
27-30
: Minor style nitpick with the 'void' operator.
Usingvoid query.limit(...)
is somewhat unconventional and may reduce readability. Consider removingvoid
unless it's strictly required by a linting rule.- if (limit) void query.limit(limit); + if (limit) query.limit(limit);backend/src/services/project/project-service.ts (2)
571-581
: Unique slug check is good but consider enforcing via DB constraint.
Your logic correctly prevents the slug collision within the same organization. For extra robustness, add a unique DB index or constraint so that concurrent updates never violate uniqueness.
587-588
: Naming consistency consideration.
You're mappingautoCapitalization
toenforceCapitalization
. Though functionally correct, consider aligning naming for clarity. Example: both asautoCapitalization
or both asenforceCapitalization
.backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts (1)
253-257
: Typo in variable name.
Consider renaminghasRequiredPriviledges
tohasRequiredPrivileges
for correct spelling.- const hasRequiredPriviledges = ... + const hasRequiredPrivileges = ...docs/documentation/platform/gateways/gateway-security.mdx (6)
15-15
: Consider adding a comma for clarity.There is a potential missing comma after “each organization (tenant) in Infisical has its own private PKI system consisting of”. Insert a comma to improve readability.
- Each organization (tenant) in Infisical has its own private PKI system consisting of: + Each organization (tenant) in Infisical has its own private PKI system, consisting of:🧰 Tools
🪛 LanguageTool
[uncategorized] ~15-~15: Possible missing comma found.
Context: ...t) in Infisical has its own private PKI system consisting of: 1. Root CA: The ult...(AI_HYDRA_LEO_MISSING_COMMA)
22-22
: Consider adding a comma for clarity.Add a comma after “This hierarchical structure ensures complete isolation between organizations”. This improves sentence flow.
- This hierarchical structure ensures complete isolation between organizations as each has its own independent certificate chain. + This hierarchical structure ensures complete isolation between organizations, as each has its own independent certificate chain.🧰 Tools
🪛 LanguageTool
[uncategorized] ~22-~22: Possible missing comma found.
Context: ...ture ensures complete isolation between organizations as each has its own independent certifi...(AI_HYDRA_LEO_MISSING_COMMA)
41-41
: Add missing article “a”.Before “certificate chain”, consider adding “a” to read more naturally: “...along with a certificate chain for verification.”
- Gateway receives a unique certificate signed by organization's Gateway CA along with certificate chain for verification + Gateway receives a unique certificate signed by the organization's Gateway CA along with a certificate chain for verification🧰 Tools
🪛 LanguageTool
[uncategorized] ~41-~41: You might be missing the article “a” here.
Context: ...by organization's Gateway CA along with certificate chain for verification ### 2. Mutual T...(AI_EN_LECTOR_MISSING_DETERMINER_A)
47-47
: Add missing article “an”.The sentence would be clearer by adding “an” before “organization’s Gateway CA.”
- Presents certificate signed by organization's Gateway CA + Presents a certificate signed by an organization's Gateway CA🧰 Tools
🪛 LanguageTool
[uncategorized] ~47-~47: You might be missing the article “an” here.
Context: ...n**: - Presents certificate signed by organization's Gateway CA - Certificate contains u...(AI_EN_LECTOR_MISSING_DETERMINER_AN)
73-73
: Add missing article “a”.Consider adding the article “a” before “unique root CA.”
- Each organization has unique root CA and intermediate CAs + Each organization has a unique root CA and intermediate CAs🧰 Tools
🪛 LanguageTool
[uncategorized] ~73-~73: You might be missing the article “a” here.
Context: ...Based Isolation - Each organization has unique root CA and intermediate CAs - Certific...(AI_EN_LECTOR_MISSING_DETERMINER_A)
109-109
: Use a hyphen for the phrase “machine-identity based”.Typically, multi-word adjectives are hyphenated.
- Machine identity based authentication + Machine-identity based authentication🧰 Tools
🪛 LanguageTool
[uncategorized] ~109-~109: This expression is usually spelled with a hyphen.
Context: ...ing of all access attempts - Machine identity based authentication(BASED_HYPHEN)
backend/src/services/secret-import/secret-import-service.ts (3)
100-103
: Ensure environment path strings are sanitized or validated.When calling
throwIfMissingSecretReadValueOrDescribePermission
, confirm thatdata.environment
anddata.path
are not untrusted or manipulated. If they can be user-provided, consider additional sanitization.
601-604
: Filter logic is clear but watch the performance for large arrays.
secretImports.filter(...)
might become a bottleneck if the number of imports is huge. Consider server-side filtering or indexing to optimize if necessary.
683-686
: Consider potential PII in decrypted secrets.Although you are using
decryptSecretRaw
withsecretValueHidden: false
, ensure logs or error messages do not inadvertently expose decrypted content.backend/src/services/secret-sync/secret-sync-service.ts (1)
182-185
: Validate environment and secretPath values.When you call
throwIfMissingSecretReadValueOrDescribePermission
, ensure that theenvironment
andsecretPath
are valid to prevent potential injection or domain confusion.backend/src/services/auth/auth-password-service.ts (3)
7-8
: Typographical fix suggestion.The function name is spelled “infisicalSymmetricEncypt” instead of “infisicalSymmetricEncrypt.” Consider renaming for consistency.
-import { infisicalSymmetricDecrypt, infisicalSymmetricEncypt } from "@app/lib/crypto/encryption"; +import { infisicalSymmetricDecrypt, infisicalSymmetricEncrypt } from "@app/lib/crypto/encryption";
23-23
: Check references toTResetPasswordV2DTO
.This new type likely impacts your routes and controllers. Ensure that new keys or properties are properly validated in request schemas.
265-265
: Remove spurious code or confirm necessity.Check if any follow-up logic is needed at line 265 or if it’s extraneous. Possibly ensure the function ends gracefully without leftover debugging statements.
backend/src/server/routes/v1/dashboard-router.ts (4)
120-123
: Metadata fields look good; confirm test coverage.
AddingsecretValueHidden
andtags
fields extends your secret object’s schema. Ensure associated test cases handle these fields (especially for partial updates or edge scenarios).Consider validating that
secretValueHidden
is set correctly in relevant service or controller code paths to enforce intended behavior.
596-613
: Expanded parameters forgetSecretsRaw
invocation.
PassingviewSecretValue
andthrowOnMissingReadValuePermission
is a logical addition for a more refined secrets read policy. Make sure it doesn’t inadvertently grant unauthorized access.Consider documenting the interplay of
viewSecretValue
+throwOnMissingReadValuePermission
in code comments for clarity.
739-739
: Use ofProjectPermissionSecretActions.DescribeSecret
.
This filter action is appropriate for read-only checks. Ensure higher-level routes that require read-value permission do not inadvertently rely on onlyDescribeSecret
.If needed, I can help map out permission checks for each environment and path combination.
837-882
: New/accessible-secrets
route.
Great approach for retrieving secrets under a specified permission action. Confirm that the route is protected behind robust org/project membership checks.Consider pagination or limiting results to prevent heavy loads or performance bottlenecks if large numbers of secrets can be returned.
backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts (1)
92-98
: Extended secret-tag DAL methods.
New entries likedeleteTagsToSecretV2
andfind
likely expand functionality. Ensure each method has coverage in unit tests, especially around edge cases (e.g., missing IDs).Add doc comments describing differences between
deleteTagsManySecret
vs.deleteTagsToSecretV2
for new team members.frontend/src/pages/auth/PasswordResetPage/PasswordResetPage.tsx (2)
31-33
: Watching form fields.
These watchers let you pass data down to child components easily. Make sure the watchers are unsubscribed or handled if the component unmounts abruptly.
38-73
: Password reset wizard flow.
The step-based conditional rendering seamlessly guides the user. Ensure correct transitions after each step, especially for edge cases (like invalid tokens or unrecognized backup keys).Consider adding success/failure notifications or alerts within each step for better user feedback.
backend/src/services/webhook/webhook-fns.ts (1)
57-100
: Consolidate or remove the redundant switch caseAt line 88,
case WebhookType.GENERAL
is effectively duplicated by the subsequentdefault:
block. You may remove one or unify them:- case WebhookType.GENERAL: default: return { ...
🧰 Tools
🪛 Biome (1.9.4)
[error] 88-88: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
🛑 Comments failed to post (7)
cli/packages/gateway/relay.go (1)
148-151:
⚠️ Potential issueRedundant nested TLS condition check.
The condition
if g.Config.isTlsEnabled {
at line 148 is nested inside an identical condition at line 137, making it redundant. Also, this creates a second certificate pool when one was already created at lines 131-132.- if g.Config.isTlsEnabled { caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM([]byte(g.Config.tlsCa)) - }Committable suggestion skipped: line range outside the PR's diff.
backend/src/queue/queue-service.ts (1)
111-111: 💡 Verification agent
🧩 Analysis chain
Updated webhook payload type to use a more structured approach.
The change from an inline object definition to the
TWebhookPayloads
type provides better type safety and enables more flexibility in webhook payloads.Let's verify this change is consistent with usage in webhook handlers:
🏁 Script executed:
#!/bin/bash # Check if webhook handlers correctly use the new payload type echo "Looking for webhook handler implementations..." rg -A 3 "QueueJobs.SecWebhook" --type tsLength of output: 988
Ensure Consistent Use of Structured Payload Types
- The change in
backend/src/queue/queue-service.ts
to useTWebhookPayloads
provides improved type safety as intended.- However, the webhook handler implementations in
backend/src/services/secret/secret-queue.ts
are still using inline object definitions for thepayload
.- To maintain consistency and fully leverage the enhanced type safety across webhook handlers, please update those inline payload definitions to use
TWebhookPayloads
as well—or verify that the inline objects meet the required type constraints.frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx (1)
300-300: 💡 Verification agent
❓ Verification inconclusive
Added 'readValue: false' default value
The default value for the new
readValue
permission is set tofalse
, which is appropriate for a permission that should be explicitly granted. However, I notice that while the schema has been updated, there's no UI element to toggle this new permission.
🏁 Script executed:
#!/bin/bash # Search for UI components that might handle the readValue permission rg -A 5 "readValue" --type tsxLength of output: 58
Below is a revised review comment. Note that the re‑run with a corrected file glob (using “-g '*.tsx'” instead of “--type tsx”) still did not reveal any UI component handling the
readValue
permission. This suggests that—aside from updating the schema—the necessary UI element to toggle this permission is missing.Missing UI Toggle for
readValue
Permission
- The new default for
readValue
is correctly set tofalse
, ensuring that the permission is only granted when explicitly enabled.- However, our search (using a file glob for TSX files) did not locate any UI element that allows users to update or toggle this permission.
- Please verify whether the omission is intentional or if a UI control should be added.
File:
frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx
(around line 300)To help further verify, please run the following script in your environment:
#!/bin/bash # Search for UI components mentioning 'readValue' in .tsx files rg -A 5 "readValue" -g "*.tsx"If any UI element exists elsewhere or if the omission was intentional, please update this comment with clarification.
backend/src/services/identity/identity-service.ts (1)
60-66:
⚠️ Potential issueEnhanced privilege validation when creating identities.
The code now uses
validatePrivilegeChangeOperation
with identity-specific actions to verify permission boundaries. However, it appears the error response still uses the old approach in lines 66-67, while lines 69-71 show the newer approach with detailed missing permissions.Consider updating the error handling to match the new pattern:
- if (!hasRequiredPriviledges) - throw new ForbiddenRequestError({ message: "Failed to create a more privileged identity" }); + if (!hasRequiredPriviledges.isValid) + throw new ForbiddenRequestError({ + name: "PermissionBoundaryError", + message: "Failed to create a more privileged identity", + details: { missingPermissions: hasRequiredPriviledges.missingPermissions } + });Committable suggestion skipped: line range outside the PR's diff.
backend/src/lib/casl/boundary.ts (1)
140-197: 🛠️ Refactor suggestion
Improve clarity within
isSubsetForSamePermissionSubjectAction
.While logic is correct, the nested loops and filtering might benefit from extraction into smaller helper functions, reducing complexity and improving readability.
frontend/src/pages/auth/PasswordResetPage/components/EnterPasswordStep.tsx (1)
1-18: 🛠️ Refactor suggestion
Check error handling for asynchronous resets.
Multiple imported libraries (e.g.,useResetPassword
,useResetPasswordV2
) handle async calls, but there is no user-facing error feedback if they fail. Presenting an error message or alert in case of failure is recommended to improve UX.try { await resetPasswordV2({...}); +} catch (error) { + // Provide user feedback, e.g. set an error state or show a toast + console.error(error); + // any desired UI feedback to the user }Committable suggestion skipped: line range outside the PR's diff.
backend/src/ee/routes/v2/identity-project-additional-privilege-router.ts (1)
6-6: 💡 Verification agent
❓ Verification inconclusive
Ensure robust tests for
checkForInvalidPermissionCombination
.
Validate that the function identifies all intended invalid combos. Confirm coverage in your unit tests so permission boundary checks are accurate.
🏁 Script executed:
#!/bin/bash # Searching for the test coverage referencing 'checkForInvalidPermissionCombination' rg -A 5 "checkForInvalidPermissionCombination" testsLength of output: 98
Robust Test Coverage Required for Permission Combination Checks
- The file
backend/src/ee/routes/v2/identity-project-additional-privilege-router.ts
importscheckForInvalidPermissionCombination
, a critical function for validating permission combinations.- Our initial search for tests referencing this function in a
tests
directory returned an error, which may indicate one of the following:
- The tests might be located elsewhere.
- Unit tests for this function are missing.
- Action Required:
Please ensure that robust unit tests are added (or properly located) to validate thatcheckForInvalidPermissionCombination
correctly identifies every invalid permission combination. The tests should cover all edge cases and boundary conditions to guarantee accurate permission boundary checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx (3)
39-55
: Enhance error handling for better user guidanceThe basic error handling works, but for a critical, permanent system upgrade, more specific error messages would be helpful. Consider capturing and displaying the specific error from the API to help users troubleshoot when upgrades fail.
try { await upgradePrivilegeSystem(); createNotification({ text: "Privilege system upgrade completed", type: "success" }); onOpenChange(false); - } catch { + } catch (error) { + const errorMessage = error instanceof Error + ? error.message + : "Failed to upgrade privilege system"; createNotification({ - text: "Failed to upgrade privilege system", + text: errorMessage, type: "error" }); }
139-227
: Consider refactoring repetitive checkbox componentsEach checkbox component has very similar props and structure. Consider creating a reusable wrapper component to reduce repetition and improve maintainability.
// Example refactored component type CheckboxFieldProps = { name: keyof typeof formSchema.shape; control: Control<z.infer<typeof formSchema>>; label: React.ReactNode; id: string; defaultValue?: boolean; }; const CheckboxField = ({ name, control, label, id, defaultValue = false }: CheckboxFieldProps) => ( <Controller control={control} name={name} defaultValue={defaultValue} render={({ field: { onBlur, value, onChange }, fieldState: { error } }) => ( <Checkbox containerClassName="items-start" className="mt-0.5 items-start" id={id} indicatorClassName="flex h-full w-full items-center justify-center" allowMultilineLabel isChecked={value} onCheckedChange={onChange} onBlur={onBlur} isError={Boolean(error?.message)} > {label} </Checkbox> )} /> ); // Usage in form <div className="flex flex-col space-y-4"> <CheckboxField control={control} name="isProjectPrivilegesUpdated" id="is-project-privileges-updated" label="I have reviewed project-level privileges and updated them if necessary" /> {/* Other checkboxes... */} </div>
229-237
: Add an explicit cancel button for better UXWhile users can likely close the modal using the standard modal close button, for critical operations like this, an explicit "Cancel" button next to the submit button would improve user experience and make it clearer how to abort the process.
- <Button - type="submit" - isDisabled={!isAdmin} - isLoading={isSubmitting} - className="mt-5 w-full" - > - {isAdmin ? "Upgrade Privilege System" : "Upgrade requires admin privilege"} - </Button> + <div className="mt-5 flex gap-3"> + <Button + variant="outline" + onClick={() => onOpenChange(false)} + className="flex-1" + > + Cancel + </Button> + <Button + type="submit" + isDisabled={!isAdmin} + isLoading={isSubmitting} + className="flex-1" + > + {isAdmin ? "Upgrade Privilege System" : "Upgrade requires admin privilege"} + </Button> + </div>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
backend/src/db/migrations/20250313124706_add-privilege-upgrade-field.ts
(1 hunks)backend/src/db/schemas/organizations.ts
(1 hunks)backend/src/server/routes/v1/organization-router.ts
(2 hunks)backend/src/server/routes/v2/organization-router.ts
(4 hunks)backend/src/services/org/org-schema.ts
(1 hunks)backend/src/services/org/org-service.ts
(7 hunks)backend/src/services/org/org-types.ts
(1 hunks)frontend/src/components/v2/Checkbox/Checkbox.tsx
(4 hunks)frontend/src/hooks/api/organization/index.ts
(1 hunks)frontend/src/hooks/api/organization/queries.tsx
(1 hunks)frontend/src/hooks/api/organization/types.ts
(1 hunks)frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
(4 hunks)frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Check API Changes
- GitHub Check: Check TS and Lint
- GitHub Check: Run integration test
- GitHub Check: Check Frontend Type and Lint check
🔇 Additional comments (31)
backend/src/services/org/org-service.ts (5)
22-29
: Updated imports reflect improved permission model structureThe imports have been updated to include more granular permission actions (
OrgPermissionGroupActions
) and the newvalidatePrivilegeChangeOperation
function. This aligns with the PR's objective of enhancing privilege management with more specific permission types.
190-195
: Improved permission model with more specific action typesThe permission check for reading organization groups now uses
OrgPermissionGroupActions.Read
instead of a more general action, reflecting a more granular permission approach. This change properly separates group operations from other organization permission checks.
286-323
: New function for privilege system upgrade with proper validationThe
upgradePrivilegeSystem
function properly checks admin privileges before allowing the upgrade and includes appropriate error handling. The transaction ensures atomicity of the database changes.A few observations:
- Admin-only access is enforced
- Proper error handling for already upgraded systems
- Audit fields (who initiated the upgrade and when) are recorded
916-935
: Enhanced permission boundary validation for project role invitationsThe code now properly validates if the user has sufficient privileges to invite users to projects with specific roles using the new
validatePrivilegeChangeOperation
function. This implementation aligns with the PR objective of bypassing permission boundary checks for privilege-related changes only when the entity has the "manage privileges" permission.The error message and details about missing permissions improve the API's usability by providing clear feedback on permission issues.
1353-1354
: Export of new functionalityThe new
upgradePrivilegeSystem
function is properly exposed in the service's return object.backend/src/services/org/org-types.ts (1)
78-78
: Added DTO type for the new upgrade privilege system functionalityThe new
TUpgradePrivilegeSystemDTO
type properly reuses the existingTOrgPermission
type, omitting theactor
field which isn't needed for this specific operation. This maintains consistency with the rest of the codebase while being tailored to the specific needs of the upgrade privilege system functionality.frontend/src/hooks/api/organization/types.ts (1)
18-18
: Added organization flag for new privilege systemThe addition of the
shouldUseNewPrivilegeSystem
boolean property to theOrganization
type allows the frontend to detect whether an organization is using the new privilege management system. This flag is essential for the frontend to know when to use the updated permission model and UI components.frontend/src/hooks/api/organization/index.ts (1)
23-24
: Exported new hook for privilege system upgradeThe addition of
useUpgradePrivilegeSystem
to the exports makes the new functionality available to components throughout the application. This hook will allow UI components to trigger the privilege system upgrade process.frontend/src/hooks/api/organization/queries.tsx (1)
130-140
: LGTM: New hook for upgrading privilege systemThe implementation of
useUpgradePrivilegeSystem
follows the established pattern of mutation hooks in this file. It properly handles the API request and cache invalidation upon success.frontend/src/components/v2/Checkbox/Checkbox.tsx (4)
20-21
: Good addition of new customization propsThese new optional properties enhance the component's flexibility by allowing custom styling for the indicator and supporting multiline labels.
35-36
: LGTM: Props destructuring updatedThe props destructuring has been properly updated to include the new properties.
55-57
: Properly implemented indicator customizationThe use of
twMerge
to combine the default styling with custom classes is a good practice for maintaining base styles while allowing customization.
66-70
: Well-implemented conditional styling for labelsThe conditional application of truncation classes based on the
allowMultilineLabel
prop is implemented correctly, maintaining backward compatibility while adding new functionality.backend/src/services/org/org-schema.ts (1)
15-18
: Schema updated for new privilege systemThe sanitized organization schema has been properly extended to include the new fields needed for the privilege system upgrade. These additions align with the PR's objective of transitioning to a new privilege management system.
backend/src/db/schemas/organizations.ts (1)
25-28
: Schema definition for new privilege system fieldsThe organization schema has been appropriately extended with well-defined types and defaults for the new privilege system fields:
- Setting default to
true
forshouldUseNewPrivilegeSystem
ensures new organizations will use the new system- Making tracking fields nullable and optional is appropriate for their purpose
This implementation aligns with the PR's goal of introducing new permissions for policy makers.
backend/src/db/migrations/20250313124706_add-privilege-upgrade-field.ts (2)
4-20
: Well-structured migration for privilege system implementation.The migration properly handles the addition of the new privilege system fields to the Organization table with a careful approach:
- Checks if columns exist before attempting modifications
- Sets default values for existing records (
false
) to maintain backward compatibility- Configures new records to use the new system by default (
true
)
22-30
: Down migration correctly reverses changes.The down migration properly checks for column existence and removes all three added columns, providing a clean rollback mechanism.
backend/src/server/routes/v1/organization-router.ts (2)
59-59
: Schema replacement improves security posture.The change from a generic schema to the sanitized organization schema enhances data safety by ensuring only necessary organization data is exposed in the API response.
264-264
: Consistent use of sanitized schema in responses.This schema update for organization updates brings consistency with the other API endpoints, ensuring sensitive data is properly filtered in all organization-related responses.
backend/src/server/routes/v2/organization-router.ts (3)
338-338
: Schema standardization applied to organization creation.The use of sanitizedOrganizationSchema provides consistent data formatting across API responses and improves security by filtering sensitive information from the response payload.
368-368
: Schema consistency maintained in deletion endpoint.Using the sanitizedOrganizationSchema for the deletion response aligns with the schema standardization across all organization endpoints.
400-424
:✅ Verification successful
New privilege system upgrade endpoint properly implemented.
The new endpoint for upgrading to the new privilege system follows best practices:
- Includes appropriate rate limiting
- Applies proper authentication
- Returns the updated organization with the sanitized schema
- Correctly passes the actor context to the service layer for permission validation
Ensure that error handling for unauthorized upgrade attempts is implemented in the service layer, as this endpoint doesn't contain explicit error handling logic.
🏁 Script executed:
#!/bin/bash # Check if the upgradePrivilegeSystem service handles permission checks rg -A 10 "upgradePrivilegeSystem" --glob "backend/src/services/org/**"Length of output: 1128
Approval: Privilege System Upgrade Endpoint Verified
- The error handling for unauthorized upgrade attempts has been successfully implemented in the service layer. The check in
backend/src/services/org/org-service.ts
confirms that if the user's membership role is notAdmin
, aForbiddenRequestError
is thrown.- The endpoint correctly applies rate limiting, authentication, returns the updated organization with the sanitized schema, and passes the proper actor context to the service layer.
frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx (5)
5-14
: More granular permission imports enhance access control.The addition of specific permission action types (
OrgPermissionGroupActions
,OrgPermissionIdentityActions
) allows for more fine-grained access control, which aligns with the privilege management v2 transition objectives.
37-37
: State added for upgrade modal management.The new state variable appropriately manages the visibility of the privilege system upgrade modal.
55-55
: Permission check updated for groups tab.Replacing the generic permission check with the more specific
OrgPermissionGroupActions.Read
improves permission granularity for the Groups tab.
61-64
: Permission check updated for identities tab.The more specific
OrgPermissionIdentityActions.Read
check replaces the generic permission check, providing better permission granularity and alignment with the v2 privilege system.
85-109
: User notification and upgrade pathway well-implemented.The UI appropriately:
- Displays an informative message explaining the benefits of the new system
- Only shows for organizations not using the new system yet
- Provides a clear upgrade pathway with a modal for more information
- Uses proper styling and iconography to draw attention
frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx (4)
1-22
: Well-structured imports and schema definitionThe component imports are well-organized, and the zod schema appropriately enforces that all checkboxes must be checked before submission. Using
z.literal(true)
for each checkbox is a good approach to ensure user confirmation for this critical operation.
57-58
: Simple and effective admin privilege checkThe admin role check is straightforward and properly used to control access to the upgrade functionality.
62-107
: Clear and informative explanation of the system upgradeThe explanatory section effectively communicates the purpose, differences, and benefits of the new permission-based system. The visual design with icons and structured sections makes it easy for users to understand the upcoming changes.
119-134
: Appropriate warning for permanent changeThe warning about the permanent nature of the upgrade is well-designed and properly highlighted with distinctive styling and an icon. This effectively communicates the critical nature of the action to users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
backend/src/services/org/org-service.ts (1)
884-891
:⚠️ Potential issueFix shadowed variable causing pipeline failure
There's a TypeScript shadowing error flagged by the linter: the
membership
variable declared on line 884 is shadowed by another declaration within this scope.Apply this fix to resolve the variable shadowing issue:
- const { permission: rolePermission } = await permissionService.getProjectPermissionByRole( + const { permission: projectRolePermission } = await permissionService.getProjectPermissionByRole( invitedRole, projectId ); const permissionBoundary = validatePrivilegeChangeOperation( membership.shouldUseNewPrivilegeSystem, ProjectPermissionMemberActions.ManagePrivileges, ProjectPermissionSub.Member, projectPermission, - rolePermission + projectRolePermission );Also applies to: 916-936
🧹 Nitpick comments (10)
backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts (4)
70-70
: Check parallel usage of both CASL validation and new boundary checks.
We seethrowUnlessCan(ProjectPermissionMemberActions.Edit, ProjectPermissionSub.Member)
and later a boundary check for the same operation. Ensure that both checks align logically and don’t produce conflicting errors for the same condition.
71-71
: Ensure variable naming clarity fortargetUserPermission, membership
.
Because we’re now returning bothpermission
andmembership
, consider renaming or adding a brief comment clarifying which permission belongs to the current actor vs. the target user. This reduces confusion for maintainers.
167-167
: Parallel permission checks for Edit and ManagePrivileges.
Similar to line 70, watch for any confusion by having two levels of permission checks. If the logic is intentional, that’s fine. Otherwise, consider consolidating them.
190-190
: Maintain consistent error phrasing.
While “Failed to update more privileged user” is descriptive, aligning the error message with the same pattern used in other methods (e.g. “Failed to add user to more privileged group”) might strengthen consistency.backend/src/ee/services/group/group-service.ts (3)
70-70
: Check typed usage of membership in org permissions.
As done with project memberships in other files, consider verifying that membership is always present before referencingmembership.shouldUseNewPrivilegeSystem
for safety.
319-319
: Fetch membership for user additions.
As with other flows, ensure membership is properly validated to distinguish old vs. new privilege system logic.
326-326
: Include a single enforcement point.
We callthrowUnlessCan(OrgPermissionGroupActions.Edit, OrgPermissionSubjects.Groups)
again. If we keep multiple calls, clearly comment on the rationale behind them to avoid double enforcement confusion.backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (2)
70-70
: Membership retrieval for identity logic.
Ensuring membership includesshouldUseNewPrivilegeSystem
is consistent with the approach used in other services. Keep an eye on possible undefined references.
78-80
: Enforcement via CASL prior to boundary check.
Line 79 (unchanged) callsthrowUnlessCan
, then lines 78/80 finalize the addition. This duplication of checks is fine if we want immediate CASL feedback plus more detailed boundary errors.backend/src/services/org/org-service.ts (1)
286-323
: Well-structured implementation of privilege system upgradeThe new
upgradePrivilegeSystem
function implements a controlled way to transition to the new privilege management system, with proper permission checks and error handling. It records when and by whom the upgrade was initiated, which is good for audit trails.Consider adding a comment or documentation explaining the specific changes that occur when the privilege system is upgraded, to help future maintenance.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
backend/src/ee/services/group/group-service.ts
(12 hunks)backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts
(11 hunks)backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts
(11 hunks)backend/src/ee/services/permission/permission-dal.ts
(10 hunks)backend/src/ee/services/permission/permission-fns.ts
(2 hunks)backend/src/ee/services/permission/permission-service.ts
(2 hunks)backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts
(8 hunks)backend/src/services/group-project/group-project-service.ts
(8 hunks)backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
(6 hunks)backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
(6 hunks)backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
(6 hunks)backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
(6 hunks)backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
(6 hunks)backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
(6 hunks)backend/src/services/identity-project/identity-project-service.ts
(10 hunks)backend/src/services/identity-token-auth/identity-token-auth-service.ts
(9 hunks)backend/src/services/identity-ua/identity-ua-service.ts
(13 hunks)backend/src/services/identity/identity-service.ts
(8 hunks)backend/src/services/org/org-service.ts
(8 hunks)backend/src/services/project-membership/project-membership-service.ts
(9 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
- backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
- backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
- backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
- backend/src/services/identity-token-auth/identity-token-auth-service.ts
- backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
- backend/src/ee/services/permission/permission-fns.ts
- backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
- backend/src/services/identity/identity-service.ts
- backend/src/services/group-project/group-project-service.ts
🧰 Additional context used
🪛 GitHub Actions: Check Backend PR types and lint
backend/src/services/org/org-service.ts
[error] 1071-1071: 'membership' is already declared in the upper scope on line 884 column 48 @typescript-eslint/no-shadow
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run integration test
🔇 Additional comments (58)
backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts (6)
6-7
: Aligned imports for refined permission checks
The switch toOrgPermissionIdentityActions
andvalidatePrivilegeChangeOperation
aligns with the updated permission model. This change looks consistent and correct.
187-187
: Enforcing 'Create' action
UsingthrowUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity)
is a clear check to ensure the current actor can create identity-level resources.
267-267
: Appropriate use of 'Edit' action
Customizing the permission check toOrgPermissionIdentityActions.Edit
correctly limits modifications to identity entities only to authorized users.
345-345
: Retrieving membership alongside permission
Storing membership in the return object is beneficial for deeper checks (e.g.,shouldUseNewPrivilegeSystem
). Verify at call sites thatmembership
is not null if the organization membership is missing.
352-352
: Supplementary 'Edit' permission check
Enforcing an additional permission check withthrowUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity)
maintains consistent security.
361-367
: Validating permission boundaries for revocation
UtilizingvalidatePrivilegeChangeOperation
withmembership.shouldUseNewPrivilegeSystem
ensures that changes to GCP auth respect the new privilege model. Confirm that any identity with more privileged roles is properly handled by the boundary checks.backend/src/ee/services/permission/permission-service.ts (2)
393-395
: Injecting 'shouldUseNewPrivilegeSystem' in service tokens
AssociatingshouldUseNewPrivilegeSystem: true
with service token membership clarifies that service tokens default to the new privilege system.
402-404
: Refined membership type definition
The newly addedshouldUseNewPrivilegeSystem
field eliminates ambiguity around which privilege system is used.backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts (13)
12-14
: Importing new privilege mechanics
Bringing invalidatePrivilegeChangeOperation
,ProjectPermissionIdentityActions
, andProjectPermissionSub
marks a shift towards the upgraded permission checks.
67-67
: Correct 'Edit' action for identity
Switching toProjectPermissionIdentityActions.Edit
ensures precise permission enforcement for identity-level edits.
70-70
: Capturing membership in target identity permission
Fetching{ permission: targetIdentityPermission, membership }
provides context needed to compare the current and target identity roles.
82-88
: Applying privilege boundary validation
UsingvalidatePrivilegeChangeOperation
withProjectPermissionIdentityActions.ManagePrivileges
helps ensure that granting new privileges doesn't exceed the assigner's capabilities.
159-160
: Ensuring 'Edit' action scope
EnforcingEdit
for a specific identity subject is logical to prevent unauthorized modifications.
162-162
: Retrieving target identity membership
Accessing the membership from the target identity's project permission cleanly sets up subsequent boundary checks.
174-180
: Expanded privilege boundary logic
IntroducingvalidatePrivilegeChangeOperation
ensures that an updated set of permissions does not exceed the original actor's scope.
242-242
: Including membership detail in permission retrieval
Storing the membership context allows for consistent use ofshouldUseNewPrivilegeSystem
throughout the privilege workflow.
251-251
: Enforcing 'Edit' for privilege deletion
throwUnlessCan(ProjectPermissionIdentityActions.Edit, ...)
ensures only authorized actors can remove additional privileges.
263-268
: Checking boundaries before privilege removal
validatePrivilegeChangeOperation
confirms that removing privileges from higher-privileged identities remains restricted unless the actor has sufficient scope.
308-308
: Accurate 'Read' action check
RequiringProjectPermissionIdentityActions.Read
for privileged detail retrieval is consistent with the new approach.
343-343
: Reading identity privileges
ApplyingProjectPermissionIdentityActions.Read
ensures that only authorized users can query identity-level privileges.
379-379
: Verifying read privileges for identity listing
CheckingProjectPermissionIdentityActions.Read
protects sensitive data, aligning with the principle of least privilege.backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts (4)
11-17
: New imports align with updated permission logic.
These additions cleanly integratevalidatePrivilegeChangeOperation
and the newly introduced permission enums fromproject-permission
. This is consistent with the recent shift towards more granular permission checks.
83-89
: Granular boundary check improves maintainability.
The introduction ofvalidatePrivilegeChangeOperation
is a clear step forward in separating logic for privilege changes. Good job ensuring consistent error details for missing permissions.
159-159
: Validate membership object.
Before accessingmembership.shouldUseNewPrivilegeSystem
, confirmmembership
exists or is defined to avoid potential runtime errors in edge cases.Would you like to check if we ever encounter a scenario in which
membership
is null or undefined? I can generate a script filtering calls togetProjectPermission
to confirm thatmembership
is always returned.
180-186
: Excellent use ofvalidatePrivilegeChangeOperation
for updates.
This block is consistent with the create flow, ensuring no escalation of privileges beyond the actor’s boundary.backend/src/ee/services/group/group-service.ts (6)
16-17
: Aligning group permissions with new actions.
This import modernizes permission checks by introducingOrgPermissionGroupActions
. The shift from general to group-specific actions is a positive step for clearer, more granular authorization.
77-77
: Good explicit CASL check for group creation.
Ensures the user can create groups at the org level, preventing silent failures. No concerns here.
91-97
: Use ofvalidatePrivilegeChangeOperation
for group creation.
This ensures the newly created group’s role cannot exceed the actor’s own privileges. The detailed error info is helpful for troubleshooting.
142-150
: Refined approach for editing groups.
The approach matches the create flow, validating membership withvalidatePrivilegeChangeOperation
. Looks cohesive and consistent.
171-177
: Confirming boundary checks when changing roles.
Preventing escalation to roles the actor shouldn’t grant is prudent. The error handling is well aligned with the rest of the code.
353-353
: Ensure consistent read permission check.
Verifying read access for group info is essential. This matches the pattern used throughout.backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (9)
12-18
: New imports for identity-based project permissions.
Excellent clarity separatingProjectPermissionIdentityActions
andProjectPermissionSub
, indicating a shift to more targeted checks for identity objects.
96-102
: Avoid privilege escalation by merging user’s existing rules.
Merging existing rules withcustomPermission
and then validating is well-structured to prevent inadvertently granting excessive privileges.
164-164
: Similar membership context as other services.
The code consistently retrievesmembership
. Make sure we handle scenarios where membership is missing or the user is partially set up.
174-174
: Explicit identity-based permission checks.
Helps confirm that the user can only update identities within their scope. No issues spotted.
190-196
: Detailed boundary check for identity updates.
Mirrors the create flow. The unified error message pattern helps admins grasp missing privileges quickly.
275-275
: Project membership retrieval for identity-based privileges.
As with other contexts, ensure the user’s membership is fully loaded prior to verifying privileges. Looks consistent so far.
284-284
: Additional CASL check for editing identity privileges.
Ensures standard read/edit separation. Straightforward usage, no concerns.
296-302
: Use ofvalidatePrivilegeChangeOperation
upon deletion.
This ensures we don’t remove privileges from an identity that the actor shouldn’t control. Good consistency with the rest of the code.
353-353
: Verify read access for identity privileges.
Matching the established pattern. This read check is necessary and consistent with the rest of the module.backend/src/services/identity-ua/identity-ua-service.ts (4)
9-10
: Good update to more specific permission actionsThe import change from
OrgPermissionActions
toOrgPermissionIdentityActions
provides better granularity for identity-related permissions. Adding thevalidatePrivilegeChangeOperation
function aligns with the PR's objective of enhancing privilege management.
175-175
: Well-structured permission granularity updatesAll permission checks have been consistently updated to use more specific identity-related actions instead of the generic permission actions. This improves type safety and makes the permission model more maintainable.
Also applies to: 266-266, 335-335, 361-361, 417-417, 485-485, 544-544, 595-595
363-376
: Improved privilege validation with feature flag supportThe code now properly utilizes
validatePrivilegeChangeOperation
with the membership'sshouldUseNewPrivilegeSystem
flag to determine if permission boundary checks should be enforced. This implements the core objective of the PR - allowing bypass of permission boundary checks when the entity has "manage privileges" permission.
377-382
: Enhanced error reporting for permission boundariesThe error handling now includes detailed information about missing permissions, which will improve debugging and provide better feedback to clients about why a permission check failed.
backend/src/services/identity-project/identity-project-service.ts (4)
5-7
: Well-aligned permission importsThe import changes correctly introduce the new validation function and use more specific identity actions for project permissions, which matches the changes in the identity service.
56-57
: Consistent API usage across servicesThe destructuring now correctly includes
membership
from the permission service, which is needed to check if the new privilege system should be applied.Also applies to: 170-171, 277-278
93-105
: Privilege validation now considers system flagThe implementation correctly uses
validatePrivilegeChangeOperation
with theshouldUseNewPrivilegeSystem
flag, supporting the new permission model while maintaining backward compatibility.
277-290
: Removed redundant permission checks for delete operationsThe removal of additional privilege checks for the delete operation (compared to other operations that still have them) is intentional and correct based on past review comments. This avoids unnecessary validation when the actor already has the "Delete identity" project-level permission.
backend/src/ee/services/permission/permission-dal.ts (2)
52-52
: Consistent data model updates for feature flaggingThe
shouldUseNewPrivilegeSystem
field has been added to all relevant database queries and schemas, creating a clean approach for feature flagging. This allows for a gradual rollout of the new privilege system and ensures that all services have access to this information when making permission decisions.Also applies to: 75-75, 123-123, 676-676, 704-704, 1023-1023, 1058-1058
1005-1005
: Proper join added for organization dataA join to the Organization table has been added to access the
shouldUseNewPrivilegeSystem
flag. This ensures that project identity permissions can utilize the new privilege system based on organization settings.backend/src/services/project-membership/project-membership-service.ts (3)
7-9
: Consistent permission import updatesThe import changes align with the pattern established in other services, ensuring consistency across the codebase for permission validation.
89-89
: Well-structured permission action updatesAll permission checks have been consistently updated to use the more specific member-related actions rather than generic project permission actions, improving type safety and code clarity.
Also applies to: 133-133, 156-156, 183-183, 264-264, 370-370, 406-406
277-289
: Robust privilege validation with improved error handlingThe update from
validatePermissionBoundary
tovalidatePrivilegeChangeOperation
includes the necessary flag for the new privilege system and provides better error reporting with details about missing permissions. This improves debugging and user experience when permission checks fail.backend/src/services/org/org-service.ts (5)
22-27
: Improved permission imports for more granular controlsThe introduction of
OrgPermissionGroupActions
andvalidatePrivilegeChangeOperation
facilitates a more granular permission system, aligning with the PR's objective of enhancing privilege management.
192-192
: More specific permission action for reading groupsChanged from using generic
OrgPermissionActions.Read
to the more specificOrgPermissionGroupActions.Read
, which provides better permission control by distinguishing group-related actions from other organization read operations.
893-895
: Updated permission action for project member creationChanged to use the more specific
ProjectPermissionMemberActions.Create
instead of a more generic permission, which aligns with the more granular permission model being implemented.
916-936
: Robust privilege boundary validation for project invitationsThis addition properly validates that users cannot be invited to roles that exceed the inviter's current privileges, implementing the permission boundary checks mentioned in the PR objectives. The structured error response with missing permissions details is excellent for debugging and user feedback.
1354-1355
: Added new function to service exportsThe new
upgradePrivilegeSystem
function is properly exported as part of the service's public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (2)
84-91
: Validate separate permission retrieval carefully.You retrieve permissions for the target identity via
ActorType.IDENTITY
. Ensure this step properly differentiates privileges of the identity being edited from the privileges of the editing actor (line 70). This separation is good for clarity but watch for any race conditions or caching issues if the data changes between calls.
165-176
: Repeated logic for retrieving permission and membership.The same pattern is repeated here for the
updateBySlug
method. While consistent, consider extracting or centralizing this repeated logic to avoid duplicates down the line, if applicable.backend/src/services/identity-ua/identity-ua-service.ts (1)
427-433
: Separate retrieval ofpermission: rolePermission
for identity.Double-check that the identity's own permission set is relevant for comparing an actor’s privileges. This distinction can be crucial for more advanced role hierarchies.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
backend/src/ee/services/group/group-service.ts
(12 hunks)backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts
(11 hunks)backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts
(11 hunks)backend/src/ee/services/permission/permission-fns.ts
(2 hunks)backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts
(8 hunks)backend/src/services/group-project/group-project-service.ts
(8 hunks)backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
(6 hunks)backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
(6 hunks)backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
(6 hunks)backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
(6 hunks)backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
(6 hunks)backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
(6 hunks)backend/src/services/identity-project/identity-project-service.ts
(10 hunks)backend/src/services/identity-token-auth/identity-token-auth-service.ts
(9 hunks)backend/src/services/identity-ua/identity-ua-service.ts
(13 hunks)backend/src/services/identity/identity-service.ts
(8 hunks)backend/src/services/org/org-service.ts
(8 hunks)backend/src/services/project-membership/project-membership-service.ts
(9 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
- backend/src/services/identity-token-auth/identity-token-auth-service.ts
- backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
- backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
- backend/src/ee/services/group/group-service.ts
- backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
- backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
- backend/src/services/group-project/group-project-service.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Check Frontend Type and Lint check
- GitHub Check: Check API Changes
- GitHub Check: Check TS and Lint
- GitHub Check: Run integration test
🔇 Additional comments (120)
backend/src/services/identity-azure-auth/identity-azure-auth-service.ts (8)
6-10
: Updated permission imports and added new utility functionsThe PR replaces
OrgPermissionActions
with the more specificOrgPermissionIdentityActions
and imports new utility functions for permission handling:constructPermissionErrorMessage
andvalidatePrivilegeChangeOperation
.This change supports the new privilege management system by providing more granular permission actions specifically for identity-related operations.
149-149
: Updated permission check to use identity-specific actionChanged from using generic
OrgPermissionActions.Create
to the more specificOrgPermissionIdentityActions.Create
, which better represents the context of creating an identity-related resource.
227-227
: Updated permission check for edit operationsSimilar to the create operation, this permission check now uses the identity-specific
OrgPermissionIdentityActions.Edit
instead of the generic action.
283-283
: Updated permission check for read operationsChanged to use
OrgPermissionIdentityActions.Read
for consistency with other identity-specific permission checks in this file.
302-308
: Now retrieving membership data with permissionsThe function now retrieves the
membership
object along with the permission data, which is needed to determine whether to use the new privilege system.
309-309
: Updated permission check for identity editingChanged to use
OrgPermissionIdentityActions.Edit
consistent with other changes.
318-324
: Replaced permission boundary validation with new systemImplemented the new privilege change validation function with additional parameters:
membership.shouldUseNewPrivilegeSystem
flag to determine which validation approach to useOrgPermissionIdentityActions.RevokeAuth
to specify the exact action being performed- Subject and permission objects for proper validation
This is a key change that implements the core functionality described in the PR objectives.
328-333
: Improved error messaging for permission boundary failuresUpdated to use the new
constructPermissionErrorMessage
function with parameters that provide more specific error context:
- Clearer error message text
- Flag to indicate whether new privilege system is in use
- Action and subject information
This makes error messages more helpful and consistent across the application.
backend/src/services/identity/identity-service.ts (11)
5-9
: Updated permission imports for identity contextsSimilar to the changes in identity-azure-auth-service.ts, this file now uses the more specific
OrgPermissionIdentityActions
instead of the generic actions, and imports the new permission utility functions.
55-62
: Now retrieving membership data with permissionsUpdated to retrieve the
membership
object along with permissions, which is necessary for the new privilege system transition logic.
69-75
: Implemented new privilege change validationReplaced the previous validation mechanism with
validatePrivilegeChangeOperation
, which now accepts:
- The flag to indicate whether to use the new privilege system
- The specific permission action for managing privileges
- The subject and permission objects
This implements the core functionality described in the PR to check for the "manage privileges" permission.
79-84
: Improved error message construction for permission failuresAdded structured error message construction that provides more context about the permission failure, including:
- Clear description of what operation failed
- Whether the new privilege system is in use
- The specific action and subject involved
This change enhances error reporting and debugging.
139-146
: Updated permission retrieval and checks for identity editingSimilar to the changes in the create function, the update function now:
- Retrieves the membership object along with permissions
- Uses identity-specific permission action (
OrgPermissionIdentityActions.Edit
)This is consistent with the changes throughout the codebase.
156-162
: Implemented new privilege validation for role changesSimilar to the create function, the update function now uses the new validation approach when checking if a user can change an identity's role.
166-171
: Improved error message for role change permission failuresUpdated error message construction similar to other locations in the file.
223-223
: Updated permission check for reading identity informationChanged to use the identity-specific action
OrgPermissionIdentityActions.Read
.
238-239
: Updated permission check for identity deletionChanged to use the identity-specific action
OrgPermissionIdentityActions.Delete
.
261-261
: Updated permission check for reading organization identitiesChanged to use the identity-specific action
OrgPermissionIdentityActions.Read
.
297-297
: Updated permission check for reading project identitiesChanged to use the identity-specific action
OrgPermissionIdentityActions.Read
.backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts (10)
11-17
: Updated permission imports and utility functionsChanged imports to use the new permission utility functions and to reference the more specific
ProjectPermissionMemberActions
and related subjects, providing better type safety and more explicit action naming.
70-78
: Now retrieving membership data with permissionsUpdated to retrieve the
membership
object along with permissions, which is necessary for the privilege system transition logic.
83-89
: Implemented new privilege validation for user permissionsUpdated to use the new validation function with:
- Flag to determine which privilege system to use
- Specific action for managing privileges on members
- Appropriate subject and permission objects
This implements the core functionality for privilege management on project users.
93-98
: Improved error message for privilege management failuresThe error message now specifically mentions "Failed to update more privileged user" rather than what was likely a more generic message before, and includes details about the new privilege system.
164-172
: Updated permission retrieval and checks for user privilege updatesNow retrieving membership data along with permissions and using the member-specific permission action.
185-191
: Implemented privilege validation for updating user permissionsSimilar to the create function, uses the new validation approach when checking if a user can update another user's privileges.
195-200
: Improved error message for privilege update failuresUpdated error message with proper context about privilege updates.
273-273
: Updated permission check for member edit operationsChanged to use the member-specific action
ProjectPermissionMemberActions.Edit
.
310-310
: Updated permission check for member read operationsChanged to use the member-specific action
ProjectPermissionMemberActions.Read
.
337-337
: Updated permission check for listing user privilegesChanged to use the member-specific action
ProjectPermissionMemberActions.Read
.backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts (16)
12-14
: Updated permission imports for identity contextsChanged imports to use the new permission utility functions and the more specific
ProjectPermissionIdentityActions
, providing better type safety and more explicit action naming for identity operations.
67-69
: Updated permission check for identity editingChanged to use the identity-specific action
ProjectPermissionIdentityActions.Edit
.
70-77
: Now retrieving membership data with permissionsUpdated to retrieve the
membership
object along with permission data for the new privilege system transition.
82-88
: Implemented new privilege validation for identity permissionsUpdated to use the new validation function with parameters specific to identity privilege management.
92-97
: Improved error message for identity privilege failuresUpdated error message construction to provide better context for permission failures.
164-166
: Updated permission check for identity edit operationsChanged to use the identity-specific action
ProjectPermissionIdentityActions.Edit
.
167-174
: Now retrieving membership for identity permission updatesSimilar to other functions, retrieving membership data needed for privilege system transition.
179-185
: Implemented privilege validation for updating identity permissionsUsing the new validation approach consistently with other functions.
189-194
: Improved error message for identity privilege update failuresProviding consistent, detailed error messages about permission failures.
252-259
: Now retrieving membership for identity permission deletionUpdated to retrieve membership data along with permissions for the delete operation as well.
261-263
: Updated permission check for identity editing during deletionChanged to use the identity-specific action
ProjectPermissionIdentityActions.Edit
.
272-278
: Implemented privilege validation for deleting identity permissionsUsing the new validation approach consistently with the other functions in this file.
282-287
: Improved error message for identity privilege deletion failuresProviding consistent, detailed error messages about permission failures during deletion.
323-325
: Updated permission check for reading identity detailsChanged to use the identity-specific action
ProjectPermissionIdentityActions.Read
.
358-360
: Updated permission check for reading identity privileges by slugChanged to use the identity-specific action
ProjectPermissionIdentityActions.Read
.
394-396
: Updated permission check for listing identity privilegesChanged to use the identity-specific action
ProjectPermissionIdentityActions.Read
.backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (14)
12-18
: Imports correctly reference newly introduced helpers.These added imports for
constructPermissionErrorMessage
andvalidatePrivilegeChangeOperation
, along withProjectPermissionIdentityActions
,ProjectPermissionSet
, andProjectPermissionSub
, properly align with the new privilege management logic. No concerns here regarding correctness or maintainability.
70-77
: Check for potential null return ofmembership
.While you correctly destructure both
permission
andmembership
, ensure that downstream logic gracefully handles the case wheremembership
might be undefined if thepermissionService
call changes or fails. This is minor but worth verifying.Would you like to confirm that
permissionService.getProjectPermission
always returns a validmembership
? If so, I can provide a shell script to search its code references and usage.
80-80
: Use identity-focused actions for clarity.Replacing the old action with
ProjectPermissionIdentityActions.Edit
reinforces the more granular identity-based permission checks. This approach is clear and consistent with the new privilege system.
96-102
: Good integration of the newvalidatePrivilegeChangeOperation
.Passing in
managePrivileges
and both the actor’s permission plus the target identity’s permission adheres to the enhanced logic. The code is straightforward and consistent with the new system’s design.
106-113
: Enhanced error handling with additional context is commendable.Providing detailed
missingPermissions
and usingconstructPermissionErrorMessage
helps users diagnose missing privileges more easily. This pattern is reliable for debugging and user clarity.
179-181
: Identity edit check remains consistent.No issues spotted. This check ensures the acting user can edit the target identity. Continue to keep these references in sync with the new privilege approach.
195-202
: Permission boundary usage for update logic is consistent.This mirrors the pattern used elsewhere (e.g., create flow) and ensures that new privilege checks remain consistent. Implementation looks solid.
205-212
: ConsistentPermissionBoundaryError
structure.Throwing
ForbiddenRequestError
withmissingPermissions
fosters a standardized approach to user feedback. Keep this consistent across all modules.
285-292
: Re-destructuringpermission
andmembership
again.Same minor caution: ensure
membership
is always defined or gracefully handled. Otherwise, code is consistent with your approach throughout the file.
293-296
: Identity edit check for deletion logic.Applying the same pattern to confirm 'edit' rights before modifying privileges is essential. Nicely aligned with the new approach.
306-312
: ReusingvalidatePrivilegeChangeOperation
for delete flow is good.Ensuring the new system handles privilege checks consistently across create, update, and delete is crucial. This usage is correct and thorough.
316-323
: Structured error message for delete boundary checks.The consistent naming and message structure helps maintain clarity. No issues found.
368-370
: Read privilege enforced for identity details.Ensuring an actor can only read identities they have explicit read permission for is a sound approach. Implementation is correct and minimal.
412-414
: Consistent read checks in list flow.Similar use of
ProjectPermissionIdentityActions.Read
for listing is fully logical; no concerns.backend/src/services/identity-ua/identity-ua-service.ts (22)
9-13
: Updated imports for identity-specific permissions and helper functions.Switching to
OrgPermissionIdentityActions
aligns with the new identity-focused approach. IncludingconstructPermissionErrorMessage
andvalidatePrivilegeChangeOperation
is consistent with the global transition.
178-178
: Use ofOrgPermissionIdentityActions.Create
to restrict identity creation is appropriate.No further issues; the code evidently constrains creation to users with the correct scope. Looks good.
269-269
: ApplyingOrgPermissionIdentityActions.Edit
for universal auth updates.Explicitly checking this action ensures you preserve robust identity-level control. Implementation is straightforward.
338-338
: Read permission for retrieving identity universal auth data.Ensures that only authorized actors can read universal auth details. This approach is consistent with the new model.
364-364
: Edit permission for revoking universal auth.This check forces the user to hold edit permissions on the identity before revoking. The logic is correct and consistent.
366-379
: Valid membership usage invalidatePrivilegeChangeOperation
.Properly destructuring
membership
to determine if new system logic is used, then verifying privileges forRevokeAuth
. This is consistent and correct.
382-390
: Granular error details are beneficial.Throwing a
PermissionBoundaryError
with a clear message andmissingPermissions
array is good for diagnosing insufficient privileges.
418-424
: Addingmembership
on org permission retrieval for client secrets creation.Consistently reusing new boundary logic in the universal auth context. No immediate issues noted.
425-425
: Create permission for identity client secrets.Aligns perfectly with the refined permission structure to specifically allow secret creation. Implementation is correct.
434-440
: Appropriate boundary check for new token creation.No logical issues spotted. The arguments to
validatePrivilegeChangeOperation
appear correct and consistent with the usage in other modules.
444-451
: Helpful error message clarifies a more privileged identity scenario.Reinforcing clarity in user feedback is always beneficial. Good job maintaining a uniform pattern for these errors.
491-497
: Valid membership retrieval for listing client secrets.Same pattern regarding membership. Ensure the
permissionService
indeed sets membership reliably to avoid null references.
498-498
: Read permission gating secret listing.Matches the rest of your approach to identity-based restrictions and maintains consistent checks for read-level access.
508-525
: Permission boundary for retrieving tokens.This is a good demonstration of the new boundary logic for reading identity tokens. Implementation is in line with your overall system changes.
555-561
: Membership retrieval for universal auth client secret operations.Continuing the pattern. No immediate issues. Keep an eye on possible error handling for missing membership in future expansions.
563-563
: Read permission for single secret retrieval.Same approach as listing secrets. This is consistent with the stronger identity-based security posture.
571-577
: Boundary check forGetToken
action.Ensures that only authorized actors can retrieve a client secret. Implementation is correct and fosters a consistent pattern across the codebase.
579-588
: Detailed error for insufficient privileges to retrieve secret.User feedback includes missing permissions. This is good for a robust debugging experience.
611-617
: Permission retrieval for revoking a client secret.Similar membership logic. The code is consistent with your approach for memory-based or DB-based membership references.
618-618
: Delete permission for revoking identity client secrets.This is a natural extension of the new identity actions. Straightforward and correct.
628-634
: Boundary check for deleting tokens.Correctly uses
validatePrivilegeChangeOperation
for a token deletion scenario. Well aligned with the rest of the permission changes.
635-646
: UnifiedPermissionBoundaryError
handling.Maintains continuity in how boundary errors are raised with helpful detail for end-users. Approved.
backend/src/ee/services/permission/permission-fns.ts (3)
6-6
: ImportingvalidatePermissionBoundary
.This import allows the new function to delegate to the old boundary logic for legacy privilege checks. The usage is clearly integrated later in the file.
10-10
: ImportingOrgPermissionSet
.Helpful if you plan to handle both project-level and organization-level permissions with the same approach. No concerns here.
150-200
: Robust bridging functions for old and new privilege systems.
validatePrivilegeChangeOperation
: Smoothly handles the transition by checking ifshouldUseNewPrivilegeSystem
is set, then either verifying a direct permission or falling back to the legacyvalidatePermissionBoundary
. The logic is clear, but be cautious about future expansions.constructPermissionErrorMessage
: Great for standardizing error messages. Potentially consider letting callers pass an optional extra message context if needed.Both functions are well-structured, improving clarity and maintainability of your permission checks.
backend/src/services/identity-project/identity-project-service.ts (14)
5-8
: Improved permission validation with new utility functionsThese new imports introduce the
validatePrivilegeChangeOperation
function which replaces the previousvalidatePermissionBoundary
function, andconstructPermissionErrorMessage
for better error message handling. Both are key components of the new privilege management system.
10-10
: Updated import to use more specific permission actionsThe import has been changed from
ProjectPermissionActions
toProjectPermissionIdentityActions
, which provides more granular control over identity-specific permissions within projects.
59-59
: Enhanced permission retrieval to include membership detailsThe destructuring now includes
membership
alongsidepermission
from thegetProjectPermission
call, which is necessary to check if the new privilege system should be used.
68-68
: Updated permission action for identity creationThe permission check now uses the more specific
ProjectPermissionIdentityActions.Create
instead of the previous generic action, improving permission granularity.
96-102
: Implemented new privilege validation logicThe privilege validation has been enhanced to use the new
validatePrivilegeChangeOperation
function which takes additional context parameters including:
- Whether to use the new privilege system
- The specific permission action (ManagePrivileges)
- The permission subject (Identity)
- Current permissions and role permissions
This provides more granular control over privilege escalation checks.
106-111
: Improved error messaging for permission boundary violationsThe error message construction has been enhanced to provide clearer information about why a permission check failed, including context about the new privilege system.
178-178
: Added membership details to permission retrievalSimilar to the earlier change, this now retrieves both permission and membership details, which is needed for the new privilege system checks.
187-187
: Updated permission action for identity editingUsing the more specific
ProjectPermissionIdentityActions.Edit
action instead of the previous generic one.
203-209
: Enhanced privilege validation for identity role changesSimilar to the earlier validation logic update, this implements the new privilege validation system when editing identity roles.
214-219
: Improved error message for privilege escalation attemptsThe error messaging now clearly indicates when a user is attempting to assign a more privileged role than they're allowed to.
290-297
: Simplified permission check for identity deletionThis section no longer performs additional privilege checks when deleting an identity, relying solely on the initial permission check. This is intentional as noted in the PR review comments.
299-299
: Updated permission action for identity deletionUsing the more specific
ProjectPermissionIdentityActions.Delete
action improves permission granularity.
327-330
: Updated permission check for listing identitiesThe permission check now uses the more specific identity-related action and directly passes the subject without needing to create a subject object.
363-363
: Updated permission action for reading identity detailsUsing the more specific
ProjectPermissionIdentityActions.Read
action for better permission control.backend/src/services/project-membership/project-membership-service.ts (12)
7-10
: Added utility functions for permission validationSimilar to the identity-project service, these imports add the necessary functions for the new privilege management system.
12-12
: Updated import to use member-specific permission actionsChanged from
ProjectPermissionActions
toProjectPermissionMemberActions
to provide more granular control over member-specific permissions.
92-92
: Updated permission action for reading project membersThis now uses the member-specific
ProjectPermissionMemberActions.Read
action.
136-136
: Updated permission action for reading a specific memberSimilar to the previous change, this uses the member-specific read permission.
159-159
: Updated permission action for reading a member by IDUpdated to use member-specific permission actions for consistency.
186-186
: Updated permission action for creating project membersNow using the member-specific
ProjectPermissionMemberActions.Create
permission.
259-259
: Enhanced permission retrieval to include membership detailsNow retrieving both permission and membership details, which is required for the new privilege system checks.
267-267
: Updated permission action for editing project membersUsing the member-specific edit permission for better granularity.
280-286
: Implemented new privilege validation for role changesSimilar to the identity service, this updates the validation logic to use the enhanced
validatePrivilegeChangeOperation
function with membership context.
290-295
: Improved error messaging for privilege boundary violationsThe error messages now provide clearer information about why a privilege change failed, including the specific role that caused the issue.
378-378
: Updated permission action for deleting project membersNow using the member-specific delete permission action.
414-414
: Updated permission action for batch deleting membersUsing the member-specific delete permission for bulk operations as well.
backend/src/services/org/org-service.ts (10)
22-26
: Enhanced organization permission importsAdded the new
OrgPermissionGroupActions
import to enable more granular control over group-related permissions at the organization level.
27-30
: Added utility functions for permission validationSimilar to other services, these imports provide the functions needed for the new privilege management system.
32-32
: Updated import to use member-specific permission actionsChanged to use
ProjectPermissionMemberActions
for consistency with the project membership service.
83-83
: Added type for privilege system upgrade operationAdded a new type definition for the privilege system upgrade operation, making the API contract clearer.
195-195
: Updated permission check for reading organization groupsNow using the more specific
OrgPermissionGroupActions.Read
permission for better granularity.
289-326
: Added capability to upgrade the privilege systemThis new function allows organization admins to upgrade to the new privilege management system. It includes:
- Validation that only admins can perform this operation
- Transaction handling to ensure atomicity
- Checks to prevent duplicate upgrades
- Auditing information about who initiated the upgrade and when
This is a critical component for organizations to opt into the new permission model.
887-887
: Enhanced project permission retrieval for member invitationsNow retrieving both permission and membership details when inviting users to projects, which enables privilege boundary checks.
896-896
: Updated permission action for creating project membersUsing the member-specific
ProjectPermissionMemberActions.Create
action for consistency.
919-944
: Added permission boundary validation for project invitationsThis significant addition checks whether the user inviting others to the project has sufficient privileges to assign the requested roles. It:
- Retrieves permission information for each requested role
- Validates privilege changes using the new validation function
- Throws detailed error messages if boundary violations are detected
- Includes information about missing permissions
This prevents privilege escalation through the invitation process.
1362-1363
: Updated exported functions listAdded the new
upgradePrivilegeSystem
function to the exported service API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx (1)
97-103
: Consider enhancing button accessibility.The upgrade button could benefit from an additional aria-label that more explicitly describes its purpose for screen reader users.
<Button colorSchema="primary" className="mt-2 w-fit text-xs" onClick={() => setIsUpgradePrivilegeSystemModalOpen(true)} + aria-label="Learn more about and upgrade to the new privilege management system" > Learn More & Upgrade </Button>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/src/ee/services/permission/permission-fns.ts
(2 hunks)frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Check TS and Lint
- GitHub Check: Run integration test
- GitHub Check: Check API Changes
- GitHub Check: Check Frontend Type and Lint check
🔇 Additional comments (9)
backend/src/ee/services/permission/permission-fns.ts (4)
6-6
: Import changes align well with new functionality.The added imports for
validatePermissionBoundary
andOrgPermissionSet
are necessary for the new functions and provide a good connection between the old and new permission systems.Also applies to: 10-10
150-182
: Good transition layer implementation between privilege systems.The
validatePrivilegeChangeOperation
function is well-designed as a transition layer with clear logic separation:
- For the new system: checks if the actor has the specific permission for the operation
- For the old system: falls back to the boundary check using
validatePermissionBoundary
The structured return object with
isValid
andmissingPermissions
provides helpful context for error handling.
184-193
: Error message construction enhances debugging.The
constructPermissionErrorMessage
function nicely extends error messages with additional context when using the new privilege system. This will be helpful for debugging and providing clearer feedback to users.
195-201
: Well-organized exports.The export statement properly includes both new functions along with existing utilities, maintaining a consistent export pattern.
frontend/src/pages/organization/AccessManagementPage/AccessManagementPage.tsx (5)
10-17
: Clean implementation of more granular permission actions.The transition from general permission actions to more specific ones (
OrgPermissionGroupActions
andOrgPermissionIdentityActions
) enhances the granularity of access control, aligning well with the PR's objective of improving privilege management.
55-56
: Good use of specific permission action for Groups tab.Replacing the general read permission with the more specific
OrgPermissionGroupActions.Read
improves permission granularity and clarity.
61-64
: Good use of specific permission action for Identities tab.The change to
OrgPermissionIdentityActions.Read
properly implements the more granular permission structure for identity management.
85-105
: Well-designed upgrade notice with clear user guidance.The conditional notice for legacy privilege system users is well implemented with informative text explaining the benefits of upgrading and a clear call-to-action.
106-109
: Clean modal implementation with proper state management.The
UpgradePrivilegeSystemModal
is correctly integrated with appropriate props for controlling visibility.
Description 📣
Project-level

Organization-level

Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets
Summary by CodeRabbit
New Features
Refactor
shouldUseNewPrivilegeSystem
into permission-related queries and data structures.Documentation