Skip to content

Commit f2273da

Browse files
committed
Allow using custom BearerTokenValidator
1 parent bf5e6f4 commit f2273da

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Passport.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class Passport
8686
*/
8787
public static $accessTokenEntity = 'Laravel\Passport\Bridge\AccessToken';
8888

89+
/**
90+
* The bearer token validator class name.
91+
*
92+
* @var string
93+
*/
94+
public static $bearerTokenValidator = 'League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator';
95+
8996
/**
9097
* The auth code model class name.
9198
*
@@ -450,6 +457,17 @@ public static function useAccessTokenEntity($accessTokenEntity)
450457
static::$accessTokenEntity = $accessTokenEntity;
451458
}
452459

460+
/**
461+
* Set the custom bearer token validator class name.
462+
*
463+
* @param string $bearerTokenValidator
464+
* @return void
465+
*/
466+
public static function useBearerTokenValidator($bearerTokenValidator)
467+
{
468+
static::$bearerTokenValidator = $bearerTokenValidator;
469+
}
470+
453471
/**
454472
* Set the auth code model class name.
455473
*

src/PassportServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ protected function registerResourceServer()
310310
$this->app->singleton(ResourceServer::class, function ($container) {
311311
return new ResourceServer(
312312
$container->make(Bridge\AccessTokenRepository::class),
313-
$this->makeCryptKey('public')
313+
$this->makeCryptKey('public'),
314+
new Passport::$bearerTokenValidator($container->make(Bridge\AccessTokenRepository::class))
314315
);
315316
});
316317
}

0 commit comments

Comments
 (0)