Created
November 22, 2021 03:50
-
-
Save fendis0709/e86f25bfa4006e20ca6a96eed8df9b4e to your computer and use it in GitHub Desktop.
Check file private and public keys before generate token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Register any authentication / authorization services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
$this->registerPolicies(); | |
// Register the Passport routes | |
Passport::routes(); | |
// Check the Oauth Key before set the token lifetime | |
// This will help when you need to run "php artisan passport:install" on server production | |
$privateKey = File::exists(storage_path('oauth-private.key')); | |
$publicKey = File::exists(storage_path('oauth-public.key')); | |
if ($privateKey && $publicKey) { | |
$server = $this->app->make(\League\OAuth2\Server\AuthorizationServer::class); | |
$server->enableGrantType(new \Laravel\Passport\Bridge\PersonalAccessGrant(), new \DateInterval('P7D')); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment