Skip to content

Commit 0a37b8e

Browse files
committed
Allow using custom BearerTokenValidator
1 parent bf5e6f4 commit 0a37b8e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,12 @@ protected function registerJWTParser()
308308
protected function registerResourceServer()
309309
{
310310
$this->app->singleton(ResourceServer::class, function ($container) {
311+
$accessTokenRepository = $container->make(Bridge\AccessTokenRepository::class);
312+
311313
return new ResourceServer(
312-
$container->make(Bridge\AccessTokenRepository::class),
313-
$this->makeCryptKey('public')
314+
$accessTokenRepository,
315+
$this->makeCryptKey('public'),
316+
new Passport::$bearerTokenValidator($accessTokenRepository)
314317
);
315318
});
316319
}

0 commit comments

Comments
 (0)