From ecf813f1f6b5dbb581dd5ba8f266d3831c3691b2 Mon Sep 17 00:00:00 2001 From: Twilight Date: Wed, 24 Jul 2024 00:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20token=20=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bootstrap/app.php | 6 +++++- config/auth.php | 4 ++++ config/oauth.php | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 7b162da..6b55c10 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,5 +1,6 @@ withRouting( web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + // $middleware->alias([ + // 'jwt' => JWTMiddleware::class + // ]); }) ->withExceptions(function (Exceptions $exceptions) { // diff --git a/config/auth.php b/config/auth.php index 0ba5d5d..c8936a3 100644 --- a/config/auth.php +++ b/config/auth.php @@ -40,6 +40,10 @@ 'driver' => 'session', 'provider' => 'users', ], + 'api' => [ + 'driver' => 'jwt', + // 'provider' => 'users', + ], ], /* diff --git a/config/oauth.php b/config/oauth.php index a94d919..e709f8b 100644 --- a/config/oauth.php +++ b/config/oauth.php @@ -4,4 +4,13 @@ 'client_id' => env('OAUTH_CLIENT_ID'), 'client_secret' => env('OAUTH_CLIENT_SECRET'), 'discovery' => env('OAUTH_DISCOVERY_URL'), + + // 如果启用,将拒绝不匹配的 aud + 'force_aud' => false, + + // 信任 aud。默认为空,如果你允许其他应用调用 api,你可以填写。 + 'trusted_aud' => [ + // 1,2,3 + 11, + ], ];