-
Notifications
You must be signed in to change notification settings - Fork 0
fix(auth): Set sanctum as default guard in config/auth.php #135
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
- Change default guard from 'web' to 'sanctum' (API-only architecture) - Add explicit sanctum guard configuration to guards array - Update documentation comments explaining API-only, token-based auth - Aligns config with actual authentication mechanism (routes use auth:sanctum) - Self-documenting: Config clearly shows React PWA + Bearer token architecture - Consistent with User model $guard_name = 'sanctum' property (#129) - No behavior change: All 207 tests passing Fixes #134 Part of: #125
💡 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 updates the default authentication guard configuration to match the actual authentication mechanism used throughout the application. SecPal uses Laravel Sanctum for stateless API token authentication, and this change makes the configuration explicitly reflect that architecture.
Key changes:
- Changed default guard from
'web'to'sanctum'inconfig/auth.php - Added explicit
sanctumguard configuration to the guards array - Updated documentation comments to clearly explain the API-only, token-based architecture
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| config/auth.php | Changed default guard to 'sanctum', added sanctum guard configuration, and updated documentation comments to explain API-only architecture |
| CHANGELOG.md | Documented the configuration change with comprehensive details about the alignment with existing authentication patterns |
💡 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! 😊 |
- New file: docs/GUARD_ARCHITECTURE.md (comprehensive guard guide) - Explains Laravel Guards: What they are, common types (web vs sanctum) - Documents SecPal architecture: API-only, token-based, stateless - Spatie Permission integration: Guard-awareness, mismatch troubleshooting - Configuration walkthrough: config/auth.php, User model, route middleware - Developer guidelines: Best practices for permissions/roles with sanctum - Migration context: EPIC #125 systematic migration from web to sanctum - Code examples: Correct vs incorrect patterns for tests, seeders, factories - Troubleshooting: Common errors (PermissionDoesNotExist, 403) with solutions - Incorporates insights from PR #134/#135: Explicit middleware best practice Fixes #130 Part of: #125
* docs(rbac): document Guard architecture and sanctum usage - New file: docs/GUARD_ARCHITECTURE.md (comprehensive guard guide) - Explains Laravel Guards: What they are, common types (web vs sanctum) - Documents SecPal architecture: API-only, token-based, stateless - Spatie Permission integration: Guard-awareness, mismatch troubleshooting - Configuration walkthrough: config/auth.php, User model, route middleware - Developer guidelines: Best practices for permissions/roles with sanctum - Migration context: EPIC #125 systematic migration from web to sanctum - Code examples: Correct vs incorrect patterns for tests, seeders, factories - Troubleshooting: Common errors (PermissionDoesNotExist, 403) with solutions - Incorporates insights from PR #134/#135: Explicit middleware best practice Fixes #130 Part of: #125 * docs: clarify Issue #134 vs PR #135 in CHANGELOG Copilot review feedback: Distinguish between issue number and PR number for clarity. Issue #134 was implemented in PR #135.
Summary
Updates
config/auth.phpto setsanctumas the default guard instead ofweb, aligning configuration with SecPal's API-only, token-based architecture.Changes
'web'→'sanctum'sanctumguard configuration to guards arrayWhy This Matters
Before: Config defaulted to
webguard (semantically incorrect for API-only app)After: Config defaults to
sanctumguard (matches actual authentication mechanism)Benefits:
$guard_name = 'sanctum'(Add $guard_name property to User model #129)auth:sanctum)Review Notes: Guard Usage in Routes
Question: Are explicit
auth:sanctumguard specifications in routes still necessary after this change?Answer: ✅ YES - They should REMAIN.
Reasoning:
Current Routes (CORRECT):
Don't Change To:
Conclusion: Keep explicit
auth:sanctumin routes. This PR only aligns the config with reality - it doesn't change the explicit route specifications (which are best practice).Testing
Specific Tests Verified
Related Issues
sanctumguard) ✅Implementation Notes
Why keep
webguard?No Breaking Changes:
auth:sanctummiddleware$guard_name = 'sanctum'guard_name='sanctum'Checklist
--no-verifybypass usedPR Size
Category: Configuration / Architecture
Effort: 15 minutes
Impact: Self-documenting configuration, architectural clarity