-
Notifications
You must be signed in to change notification settings - Fork 0
feat: User Direct Permission Assignment API (Issue #138) #158
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
Conversation
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 adds CHANGELOG documentation for the User Direct Permission Assignment API feature (Issue #138), which is part of RBAC Phase 4 Epic. The PR documents 4 new API endpoints for managing direct user permissions, along with supporting infrastructure (controller, policy, form request, and model method).
Key Issue: The CHANGELOG contains several inconsistencies with the PR description regarding implementation details, particularly around column names and migration requirements.
Implements Issue #138 - User Direct Permission Assignment API as part of RBAC Phase 4 Epic (#108). Added: - UserPermissionController: 4 endpoints (index, store, destroy, direct) - AssignUserPermissionRequest: Validation with temporal constraints - UserPermissionPolicy: Authorization (Admin assign/revoke, User view own) - Migration: Add temporal columns to model_has_permissions table - Tests: 13 comprehensive feature tests (52 assertions) Technical Implementation: - Direct DB manipulation for pivot attributes (Spatie limitation workaround) - hasDirectPermission() rewritten with direct DB queries (multi-tenant fix) - Temporal tracking: granted_at, granted_by, revoked_at, revoked_by Quality Assurance: - Tests: 270 passed (866 assertions) - PHPStan: Level Max, 0 errors - Laravel Pint: All files formatted - REUSE: 100% compliant
- Clarify 'List all user permissions (direct + inherited from roles)' - Change 'temporal constraints' to 'temporal tracking (audit trail)' - Fix migration description: no new migration, uses existing columns - Update column names: granted_at/granted_by/revoked_at/revoked_by (not valid_from/until) - Clarify validation description: permission existence, not already assigned Addresses 5 Copilot review comments on PR #158
💡 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! 😊 |
💡 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! 😊 |
Overview
Implements User Direct Permission Assignment API as part of RBAC Phase 4 Epic (#108).
Closes #138
Implementation Summary
API Endpoints
GET /api/v1/users/{user}/permissions- List all user permissions (direct + inherited)POST /api/v1/users/{user}/permissions- Assign direct permissionDELETE /api/v1/users/{user}/permissions/{permission}- Revoke direct permissionGET /api/v1/users/{user}/permissions/direct- List only direct permissionsKey Features
Technical Details
Critical Implementation: Direct DB manipulation required for pivot attributes
givePermissionTo()doesn't support custom pivot dataupdateOrInsert()onmodel_has_permissionstableMulti-Tenant Fix:
hasDirectPermission()rewrittenFiles Changed
app/Http/Controllers/Api/V1/UserPermissionController.php(new)app/Http/Requests/AssignUserPermissionRequest.php(new)app/Policies/UserPermissionPolicy.php(new)app/Models/User.php(updated hasDirectPermission())app/Providers/AppServiceProvider.php(Gate registration)tests/Feature/UserPermissionAssignmentApiTest.php(new, 13 tests)CHANGELOG.md(updated)Quality Assurance
Testing
Migration
No new migration required. Uses existing
model_has_permissionstable with pivot columns:granted_at,granted_by,revoked_at,revoked_byNext Steps
Epic: #108 (RBAC Phase 4)
Type: Feature
Scope: Backend API