Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
7 changes: 5 additions & 2 deletions src/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
});
}
Expand Down