Skip to content

Commit 88522fa

Browse files
committed
Configure passport
1 parent 5a07094 commit 88522fa

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

app/Providers/AuthServiceProvider.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
2-
32
namespace App\Providers;
43

4+
use Carbon\Carbon;
55
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Passport\Passport;
67
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
78

89
class AuthServiceProvider extends ServiceProvider
910
{
11+
1012
/**
1113
* The policy mappings for the application.
1214
*
1315
* @var array
1416
*/
1517
protected $policies = [
16-
'App\Model' => 'App\Policies\ModelPolicy',
18+
'App\Model' => 'App\Policies\ModelPolicy'
1719
];
1820

1921
/**
@@ -25,6 +27,13 @@ public function boot()
2527
{
2628
$this->registerPolicies();
2729

28-
//
30+
Passport::routes(function ($router) {
31+
$router->forAccessTokens();
32+
$router->forPersonalAccessTokens();
33+
$router->forTransientTokens();
34+
});
35+
36+
Passport::tokensExpireIn(Carbon::now()->addMinutes(10));
37+
Passport::refreshTokensExpireIn(Carbon::now()->addDays(10));
2938
}
3039
}

app/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use Illuminate\Notifications\Notifiable;
66
use Illuminate\Foundation\Auth\User as Authenticatable;
7+
use Laravel\Passport\HasApiTokens;
78

89
class User extends Authenticatable
910
{
10-
use Notifiable;
11+
use HasApiTokens, Notifiable;
1112

1213
/**
1314
* The attributes that are mass assignable.

config/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
],
4343

4444
'api' => [
45-
'driver' => 'token',
45+
'driver' => 'passport',
4646
'provider' => 'users',
4747
],
4848
],

0 commit comments

Comments
 (0)