Skip to content

Commit

Permalink
Updated to Passport for API
Browse files Browse the repository at this point in the history
  • Loading branch information
willbrowningme committed Oct 11, 2019
1 parent 6ba4ba6 commit 81f7b35
Show file tree
Hide file tree
Showing 19 changed files with 1,315 additions and 107 deletions.
31 changes: 0 additions & 31 deletions app/Http/Controllers/Api/ApiTokenController.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],

'api' => [
Expand Down
9 changes: 8 additions & 1 deletion app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
Expand All @@ -24,6 +25,12 @@ public function boot()
{
$this->registerPolicies();

//
Passport::routes(function ($router) {
$router->forPersonalAccessTokens();
}, ['middleware' => ['web', 'auth', '2fa']]);

Passport::personalAccessClientId(1);

Passport::cookie('anonaddy_token');
}
}
4 changes: 2 additions & 2 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable, HasUuid, HasEncryptedAttributes;
use Notifiable, HasUuid, HasEncryptedAttributes, HasApiTokens;

public $incrementing = false;

Expand Down Expand Up @@ -48,7 +49,6 @@ class User extends Authenticatable implements MustVerifyEmail
*/
protected $hidden = [
'password',
'api_token',
'remember_token',
'two_factor_secret',
'two_factor_backup_code'
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"doctrine/dbal": "^2.9",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.0",
"laravel/passport": "^7.5",
"laravel/tinker": "^1.0",
"mews/captcha": "^3.0.0",
"php-mime-mail-parser/php-mime-mail-parser": "^5.0",
Expand Down
Loading

0 comments on commit 81f7b35

Please sign in to comment.