feat: add configurable authentication guard#34
Closed
muyaedward wants to merge 1 commit intoawcodes:3.xfrom
Closed
feat: add configurable authentication guard#34muyaedward wants to merge 1 commit intoawcodes:3.xfrom
muyaedward wants to merge 1 commit intoawcodes:3.xfrom
Conversation
Adds ability to specify a custom authentication guard in mason.php config. This allows Mason to work seamlessly with applications that use multiple guards, such as Filament admin panels with custom 'admin' guards. Configuration: - New 'guard' option in config/mason.php - Defaults to null (uses default auth guard) - Set to 'admin', 'web', 'sanctum', etc. as needed Benefits: - Eliminates need to override Mason routes in AppServiceProvider - Maintains backward compatibility (null = default guard) - Simple one-line configuration - Works with any Laravel authentication guard Example usage: ```php // config/mason.php 'guard' => 'admin', // For Filament admin panels ``` Closes requirement for custom guard support in multi-guard applications.
Owner
|
Thank you for the PR, but I want to go with a more open ended solution. It will be available in the next release later today. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the ability to configure a custom authentication guard for Mason routes, eliminating the need to override routes in
AppServiceProviderwhen using multiple authentication guards.Problem
Currently, Mason's routes are hardcoded with the default
authmiddleware, which uses the default authentication guard fromconfig/auth.php. This causes issues when:admin)sanctumor custom guardsCurrent workaround:
Solution
Add a simple
guardconfiguration option toconfig/mason.php:Changes
1. config/mason.php - New configuration option
guardconfig option with comprehensive documentationnull(uses default auth guard)2. routes/web.php - Dynamic guard usage
Usage
For Filament Admin Panels:
For API applications:
For default behavior (no change needed):
Benefits
✅ Simple - One-line configuration
✅ Backward Compatible - Existing installations work unchanged
✅ Flexible - Works with any Laravel guard
✅ Clean - Removes need for route overrides
✅ Well Documented - Clear config comments
Testing
guard => null(default behavior maintained)guard => 'admin'(Filament admin panel integration)Related Issues
This addresses a common pain point for users integrating Mason with Filament admin panels and other multi-guard Laravel applications.
Migration Guide
No migration needed! Existing installations continue working without changes. To use a custom guard:
php artisan vendor:publish --tag=mason-config'guard' => 'admin'inconfig/mason.phpAppServiceProvider(if any)