Skip to content

Instantly share code, notes, and snippets.

@mrron313
Created November 14, 2019 09:28
Show Gist options
  • Save mrron313/b342732ff3a48e7b9f892e85487e3c98 to your computer and use it in GitHub Desktop.
Save mrron313/b342732ff3a48e7b9f892e85487e3c98 to your computer and use it in GitHub Desktop.
<?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