mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand code to support laravel passport
This commit is contained in:
parent
ca8b4cb11a
commit
f1d77bdb50
@ -44,7 +44,7 @@ use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
|||||||
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
use \Laravel\Passport\Http\Middleware\CreateFreshApiToken;
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* Class Kernel
|
* Class Kernel
|
||||||
@ -84,7 +84,7 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
CreateFreshApiToken::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
// MUST NOT be logged in. Does not care about 2FA or confirmation.
|
// MUST NOT be logged in. Does not care about 2FA or confirmation.
|
||||||
@ -95,7 +95,6 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
|
||||||
Binder::class,
|
Binder::class,
|
||||||
RedirectIfAuthenticated::class,
|
RedirectIfAuthenticated::class,
|
||||||
],
|
],
|
||||||
@ -109,7 +108,6 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
|
||||||
Binder::class,
|
Binder::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
RedirectIfTwoFactorAuthenticated::class,
|
RedirectIfTwoFactorAuthenticated::class,
|
||||||
@ -125,7 +123,6 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
|
||||||
Binder::class,
|
Binder::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
],
|
],
|
||||||
@ -141,11 +138,11 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
AuthenticateTwoFactor::class,
|
AuthenticateTwoFactor::class,
|
||||||
Range::class,
|
Range::class,
|
||||||
Binder::class,
|
Binder::class,
|
||||||
|
CreateFreshApiToken::class,
|
||||||
],
|
],
|
||||||
// MUST be logged in
|
// MUST be logged in
|
||||||
// MUST have 2fa
|
// MUST have 2fa
|
||||||
@ -159,12 +156,12 @@ class Kernel extends HttpKernel
|
|||||||
StartFireflySession::class,
|
StartFireflySession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
//SubstituteBindings::class,
|
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
AuthenticateTwoFactor::class,
|
AuthenticateTwoFactor::class,
|
||||||
IsAdmin::class,
|
IsAdmin::class,
|
||||||
Range::class,
|
Range::class,
|
||||||
Binder::class,
|
Binder::class,
|
||||||
|
CreateFreshApiToken::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
@ -44,5 +45,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
Passport::ignoreMigrations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Providers;
|
namespace FireflyIII\Providers;
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
@ -46,5 +47,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
$this->registerPolicies();
|
||||||
|
Passport::routes();
|
||||||
|
Passport::tokensExpireIn(now()->addDays(14));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Passport\HasApiTokens;
|
||||||
use Log;
|
use Log;
|
||||||
use Request;
|
use Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
@ -39,7 +40,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
*/
|
*/
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use Notifiable;
|
use Notifiable, HasApiTokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
@ -64,7 +64,7 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'driver' => 'token',
|
'driver' => 'passport',
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user