Created
November 14, 2019 09:28
-
-
Save mrron313/b342732ff3a48e7b9f892e85487e3c98 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace App\Providers; | |
use App\Auth\Grants\OtpGrant; | |
use Laravel\Passport\Passport; | |
use Illuminate\Support\Facades\Gate; | |
use Laravel\Passport\Bridge\RefreshTokenRepository; | |
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | |
use League\OAuth2\Server\AuthorizationServer; | |
class AuthServiceProvider extends ServiceProvider | |
{ | |
/** | |
* The policy mappings for the application. | |
* | |
* @var array | |
*/ | |
protected $policies = [ | |
'App\Model' => 'App\Policies\ModelPolicy', | |
]; | |
/** | |
* Register any authentication / authorization services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
$this->registerPolicies(); | |
app(AuthorizationServer::class)->enableGrantType( | |
$this->makeOtpGrant(), Passport::tokensExpireIn() | |
); | |
Passport::routes(); | |
} | |
protected function makeOtpGrant() | |
{ | |
$grant = new OtpGrant( | |
$this->app->make(RefreshTokenRepository::class) | |
); | |
$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); | |
return $grant; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment