diff --git a/src/Passport.php b/src/Passport.php index d1a6c0e90..d8782905c 100644 --- a/src/Passport.php +++ b/src/Passport.php @@ -86,6 +86,13 @@ class Passport */ public static $accessTokenEntity = 'Laravel\Passport\Bridge\AccessToken'; + /** + * The bearer token validator class name. + * + * @var string + */ + public static $bearerTokenValidator = 'League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator'; + /** * The auth code model class name. * @@ -450,6 +457,17 @@ public static function useAccessTokenEntity($accessTokenEntity) static::$accessTokenEntity = $accessTokenEntity; } + /** + * Set the custom bearer token validator class name. + * + * @param string $bearerTokenValidator + * @return void + */ + public static function useBearerTokenValidator($bearerTokenValidator) + { + static::$bearerTokenValidator = $bearerTokenValidator; + } + /** * Set the auth code model class name. * diff --git a/src/PassportServiceProvider.php b/src/PassportServiceProvider.php index 99e345e17..c30465466 100644 --- a/src/PassportServiceProvider.php +++ b/src/PassportServiceProvider.php @@ -308,9 +308,12 @@ protected function registerJWTParser() protected function registerResourceServer() { $this->app->singleton(ResourceServer::class, function ($container) { + $accessTokenRepository = $container->make(Bridge\AccessTokenRepository::class); + return new ResourceServer( - $container->make(Bridge\AccessTokenRepository::class), - $this->makeCryptKey('public') + $accessTokenRepository, + $this->makeCryptKey('public'), + new Passport::$bearerTokenValidator($accessTokenRepository) ); }); }