Allow for configuration of which login route to use
robertmarney opened this issue · comments
I am happy to do the leg work as required, but wanted to get a feeling for whether a PR would be acceptable before I began.
We have multiple authentication in our Laravel app, and for passport we require the users authenticate via a secondary login route (for clarity our primary login is /login
and the desired passport login is /sso/login
.
I believe if we were to extend those places where an Laravel\Passport\Exceptions\AuthenticationException
is thrown to utilize the existing redirectTo
property on the base Illuminate\Auth\AuthenticationException
to direct the user to be logged in via the correct route.
e.g.
class CheckClientCredentialsForAnyScope extends CheckCredentials
{
/**
* Validate token credentials.
*
* @param \Laravel\Passport\Token $token
* @return void
*
* @throws \Laravel\Passport\Exceptions\AuthenticationException
*/
protected function validateCredentials($token)
{
if (! $token) {
throw new AuthenticationException(redirectTo: config('passport.login_route'));
}
}
I envisage the route name being an optional config value that can be configured in passport.php
Heya. Honestly, just feel free to attempt a PR to see if Taylor would accept it 👍