-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement SecretController with shared secrets filter (#187) #191
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
…187) - Extend SecretPolicy with share() and viewShares() methods (9 total) - Implement filter parameter in index() (owned/shared/all) - Share-based access respects expires_at validation - 22 comprehensive feature tests (require DDEV for execution) - All quality gates passed: PHPStan level max, Pint, REUSE - Create GitHub Issue #190 for tenant resolution tech debt - Update CHANGELOG.md with detailed implementation notes Part of: #182
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 implements the SecretController's index() method with a new filtering mechanism that allows users to view owned, shared, or all secrets. It also extends the SecretPolicy with two new authorization methods for sharing functionality.
- Adds filter parameter support (
owned,shared,all) to the secrets listing endpoint - Extends SecretPolicy with
share()andviewShares()authorization methods - Updates CHANGELOG to document the new filtering functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| app/Http/Controllers/Api/V1/SecretController.php | Added filter parameter logic with three modes: owned (user's secrets), shared (secrets shared with user via SecretShare), and all (combination of both) |
| app/Policies/SecretPolicy.php | Added two new policy methods (share(), viewShares()) for share-related authorization using admin permission checks |
| CHANGELOG.md | Updated documentation to reflect filter parameter options and clarified that default is now 'all' instead of 'owned' |
- Add 3 filter parameter tests (owned, shared, all) - covers lines 119-129 - Add 12 SecretPolicy tests (restore, forceDelete, share, viewShares) - SecretController: 97.4% coverage (only TenantKey error case missing) - SecretPolicy: 100% coverage - Total: 37 tests (121 assertions) Addresses TDD compliance - all new code paths now tested.
- Add IndexSecretRequest for filter parameter validation - Validates filter as one of: all, owned, shared - Returns clear error message for invalid values - Extract share filter logic to Secret::scopeSharedWith() - Eliminates DRY violation between 'shared' and 'default' cases - Improves maintainability and testability - Cache user role IDs to avoid N+1 query issues - Pluck role IDs once before match expression - Reuse across both 'shared' and 'default' filter cases - Fix CHANGELOG inconsistency: default filter is 'all', not 'owned' - Add PHPStan type hints for array<int> role IDs - Add test for invalid filter parameter validation All review comments from Copilot PR Reviewer addressed. Resolves: #191 review comments
✅ All Review Comments AddressedI've systematically addressed all 5 Copilot review comments: 1. ✅ Filter Validation (Comment #2532795625)Fixed: Created 2. ✅ N+1 Query - Role IDs (Comment #2532795638)Fixed: Cached 3. ✅ Duplicate Role Query (Comment #2532795651)Fixed: Same solution as #2 - single 4. ✅ Code Duplication - Share Filter Logic (Comment #2532795664)Fixed: Extracted share filtering logic into 5. ✅ CHANGELOG Inconsistency (Comment #2532795685)Fixed: Corrected CHANGELOG to reflect Code Quality:
Changes Summary:
All CI checks green ✅ |
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 7 out of 7 changed files in this pull request and generated 2 comments.
…dling - Use explicit match expression return value capture (clearer intent) - Skip orWhereIn for empty roleIds array (query optimization) - Update CHANGELOG with implementation details (filter validation, N+1 fix, DRY scope) Addresses Copilot review comments #2539257460 and #2539257492
🎯 Summary
This PR implements the SecretController CRUD API with shared secrets filtering functionality as specified in issue #187.
📋 Changes
SecretController Enhancements
index():owned,shared,allwhereHas('shares')with user_id/role_id checksSecretPolicy Extensions
share(),viewShares())userHasPermission($user, 'admin')checkDocumentation
✅ Quality Gates (Local)
🔗 Related Issues
Fixes #187
Part of: #182
📝 Notes
TenantKey::first()pattern (documented in Bug: Tenant ID hardcoded in SecretController::store() - needs proper resolution #190)