-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(auth-admin): Allow non super admin to change Legal Representative Delegation type #17107
Conversation
WalkthroughThe changes in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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
Documentation and Community
|
Datadog ReportBranch report: ✅ 0 Failed, 2 Passed, 0 Skipped, 6.93s Total Time |
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 and nitpick comments (1)
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1)
Line range hint
1-150
: Add explicit type annotations for better type safety.While the component follows good practices for reusability and tree-shaking, it could benefit from explicit type annotations:
Consider adding these TypeScript improvements:
- const toggleDelegationType = (field: string, checked: boolean) => { + const toggleDelegationType = (field: string, checked: boolean): void => { - const providers = delegationProviders.map( + const providers: Array<ReturnType<typeof getDelegationProviderTranslations>> = delegationProviders.map( - const [inputValues, setInputValues] = useEnvironmentState<{ + interface DelegationState { + isAccessControlled: boolean + grantToAuthenticatedUser: boolean + supportedDelegationTypes: string[] + addedDelegationTypes: string[] + removedDelegationTypes: string[] + } + const [inputValues, setInputValues] = useEnvironmentState<DelegationState>({
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (1)
libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx (1)
121-122
: LGTM, but verify security implications.
The changes align with the PR objective to allow non-super admins to change Legal Representative Delegation type. The code correctly excludes only PersonalRepresentativeRegistry
for non-super admins.
Let's verify that proper access controls are in place for DistrictCommissionersRegistry
:
✅ Verification successful
Security implications verified, changes are safe
The code changes are safe because:
- The
isSuperAdmin
check is still in place, ensuring only super admins can accessPersonalRepresentativeRegistry
- The
DistrictCommissionersRegistry
(Legal Representative) access is controlled through the standard delegation type system as shown in theAuthDelegationType
enum - The component properly handles delegation type toggling with
addedDelegationTypes
andremovedDelegationTypes
tracking
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for access control implementations related to DistrictCommissionersRegistry
# Search for access control checks
rg -A 5 "DistrictCommissionersRegistry" --type typescript
# Search for related permission checks
ast-grep --pattern 'if ($CHECK && $AUTH) {
$$$
DistrictCommissionersRegistry
$$$
}'
Length of output: 184
Script:
#!/bin/bash
# Search for access control checks with proper file extension
rg -A 5 "DistrictCommissionersRegistry" --type ts --type tsx
# Search for permission-related imports and usage
rg "import.*AuthDelegationProvider" --type ts --type tsx -A 3
# Search for any security or permission checks in the same directory
fd . "libs/portals/admin/ids-admin/src/screens/Permission" -e ts -e tsx --exec rg -l "hasPermission|isAuthorized|canAccess|isSuperAdmin"
Length of output: 497
Script:
#!/bin/bash
# Check the content of the permission-related files
cat libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionAccessControl.tsx
cat libs/portals/admin/ids-admin/src/screens/Permission/components/PermissionDelegations.tsx
# Search for enums and types related to delegation providers
rg -g "*.{ts,tsx}" "enum.*AuthDelegationProvider|type.*AuthDelegationProvider"
Length of output: 9968
Script:
#!/bin/bash
# Check the enum definition and its usage
cat libs/shared/types/src/lib/delegation.ts
# Check for any additional permission checks in the context hooks
cat libs/portals/admin/ids-admin/src/hooks/useSuperAdmin.ts
Length of output: 753
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17107 +/- ##
=======================================
Coverage 35.68% 35.68%
=======================================
Files 6946 6946
Lines 147401 147401
Branches 41904 41904
=======================================
+ Hits 52600 52601 +1
+ Misses 94801 94800 -1 Flags with carried forward coverage won't be shown. Click here to find out more. see 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
What
☝️
Why
So non super admins can update Legal Representative in IDS admin
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
DistrictCommissionersRegistry
.Bug Fixes