-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve permission naming conflict and add RBAC integration tests #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve permission naming conflict and add RBAC integration tests #162
Conversation
💡 Tip: Consider Using Draft PRsBenefits of opening PRs as drafts initially:
How to convert:
This is just a friendly reminder - feel free to continue as is! 😊 |
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.
Pull Request Overview
This PR resolves a critical permission naming conflict between Phase 3 and Phase 4 RBAC implementations where Phase 3 routes expected role.* permissions but the seeder only created roles.* permissions. The fix adds both permission groups to enable all RBAC functionality. Additionally, comprehensive integration tests validate the complete RBAC system behavior, and documentation URLs are corrected to reflect production API paths.
Key Changes:
- Added missing
role.*permissions (assign, read, revoke) to seeder alongside existingroles.*permissions - Implemented 8 integration tests covering temporal role lifecycle, permission inheritance, and error handling scenarios
- Updated API documentation URLs from
/api/v1/to/v1/across 9 files to match production API structure
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| database/seeders/RolesAndPermissionsSeeder.php | Added role.* permission group for Phase 3 compatibility and updated Admin role wildcards |
| tests/Feature/Integration/RbacIntegrationTest.php | New comprehensive integration test suite with 8 tests covering temporal roles, permission inheritance, and edge cases |
| CHANGELOG.md | Documented permission naming bug fix and existing Phase 4 features under v0.2.0 |
| docs/rbac-architecture.md | Corrected API endpoint URLs from /api/v1/ to /v1/ in examples and tables |
| docs/guides/temporal-roles.md | Updated API endpoint URLs in HTTP examples throughout the guide |
| docs/guides/role-management.md | Fixed API endpoint URLs in code examples |
| docs/guides/permission-system.md | Corrected API endpoint URLs in bash examples |
| docs/guides/direct-permissions.md | Updated API endpoint URLs in HTTP request examples |
| docs/api/rbac-endpoints.md | Corrected all endpoint URLs and cURL examples |
| docs/GUARD_ARCHITECTURE.md | Fixed API endpoint URL in test example |
| README.md | Updated RBAC feature section and corrected API endpoint URLs |
- Fix permission naming bug: Add role.* permissions (assign, read, revoke) for Phase 3 route compatibility alongside roles.* for Phase 4 - Update Admin role to include both permission groups (40 permissions total) - Correct API URL paths in documentation (/api/v1/ → /v1/) - Add 8 RBAC integration tests (7 passing, 1 skipped) - Document bug fix in CHANGELOG.md Fixes #108
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.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
|
✅ Copilot suggestion already implemented The typo Details:
The old review comment refers to commit |
🐛 Bug Fix: Permission Naming Conflict
Problem
Phase 3 RBAC routes (
RoleController) use middlewarepermission:role.assign,permission:role.read,permission:role.revoke, but the seeder only createdroles.assign_temporary,roles.read, etc. This caused authorization failures because the permissions didn't match.Root Cause
Phase 3 (implemented earlier) used singular permission names:
role.assign(assign role to user)role.read(view user's roles)role.revoke(remove role from user)Phase 4 (implemented later) used plural permission names for management:
roles.read(list all roles)roles.create(create new role)roles.update(update role)roles.delete(delete role)roles.assign_temporary(assign temporal role)roles.extend_expiration(extend role expiration)The seeder only created the Phase 4 permissions, leaving Phase 3 routes broken.
Solution
✅ Added both permission groups to seeder:
role.*permissions (3):assign,read,revoke(Phase 3)roles.*permissions (6):read,create,update,delete,assign_temporary,extend_expiration(Phase 4)✅ Updated Admin role to have both wildcards:
role.*+roles.*✅ Admin now has 40 permissions (was 37)
✨ Integration Tests
Added 8 comprehensive RBAC integration tests covering:
Test Coverage
Temporal Role Lifecycle (2 tests)
Permission Inheritance (2 tests)
Multi-User Scenarios (1 test)
Error Handling (3 tests)
Test Results
📝 Documentation Updates
URL Path Corrections
Fixed all API URLs from
/api/v1/to/v1/for production API consumers:README.mdCHANGELOG.mddocs/api/rbac-endpoints.mddocs/guides/role-management.mddocs/guides/permission-system.mddocs/guides/temporal-roles.mddocs/guides/direct-permissions.mddocs/rbac-architecture.mddocs/GUARD_ARCHITECTURE.mdRationale: Production API is at
https://api.secpal.app/v1/...(no/api/prefix in URL). Internal Laravel routing uses/api/v1/, but external documentation should show the consumer-facing URL.🧪 Testing
All Quality Gates Passing
Test Statistics
📊 Changes Summary
Modified Files (10)
database/seeders/RolesAndPermissionsSeeder.php- Addedrole.*permission groupCHANGELOG.md- Documented bug fix under v0.2.0 "Fixed" sectionREADME.md- URL correctionsNew Files (1)
tests/Feature/Integration/RbacIntegrationTest.php(282 lines)Lines Changed
🔗 Related Issues
Fixes #108 (RBAC Phase 4: Documentation & Final Testing)
Part of: Epic #5 (RBAC System)
✅ Acceptance Criteria
firstOrCreate)🚀 Impact
This PR completes RBAC Phase 4 by:
📝 Reviewer Notes
->skip())role.*androles.*are intentional (Phase 3 vs Phase 4 compatibility)Type: Bug Fix + Enhancement
Priority: High (blocks Phase 4 completion)
Breaking Changes: None