22
33namespace Pterodactyl \Http ;
44
5- use Pterodactyl \Models \ApiKey ;
65use Illuminate \Auth \Middleware \Authorize ;
76use Illuminate \Auth \Middleware \Authenticate ;
87use Illuminate \Http \Middleware \TrustProxies ;
1615use Illuminate \Routing \Middleware \ThrottleRequests ;
1716use Pterodactyl \Http \Middleware \LanguageMiddleware ;
1817use Illuminate \Foundation \Http \Kernel as HttpKernel ;
19- use Pterodactyl \Http \Middleware \Api \AuthenticateKey ;
2018use Illuminate \Routing \Middleware \SubstituteBindings ;
2119use Illuminate \Session \Middleware \AuthenticateSession ;
2220use Illuminate \View \Middleware \ShareErrorsFromSession ;
2523use Illuminate \Auth \Middleware \AuthenticateWithBasicAuth ;
2624use Pterodactyl \Http \Middleware \Api \AuthenticateIPAccess ;
2725use Illuminate \Foundation \Http \Middleware \ValidatePostSize ;
28- use Pterodactyl \Http \Middleware \Api \HandleStatelessRequest ;
2926use Illuminate \Cookie \Middleware \AddQueuedCookiesToResponse ;
3027use Pterodactyl \Http \Middleware \Api \Daemon \DaemonAuthenticate ;
3128use Pterodactyl \Http \Middleware \RequireTwoFactorAuthentication ;
3229use Illuminate \Foundation \Http \Middleware \CheckForMaintenanceMode ;
3330use Illuminate \Foundation \Http \Middleware \ConvertEmptyStringsToNull ;
3431use Pterodactyl \Http \Middleware \Api \Client \SubstituteClientBindings ;
32+ use Laravel \Sanctum \Http \Middleware \EnsureFrontendRequestsAreStateful ;
3533use Pterodactyl \Http \Middleware \Api \Application \AuthenticateApplicationUser ;
3634
3735class Kernel extends HttpKernel
@@ -67,29 +65,19 @@ class Kernel extends HttpKernel
6765 RequireTwoFactorAuthentication::class,
6866 ],
6967 'api ' => [
70- HandleStatelessRequest::class,
7168 IsValidJson::class,
72- StartSession::class,
73- AuthenticateSession::class,
74- VerifyCsrfToken::class,
69+ EnsureFrontendRequestsAreStateful::class,
70+ 'auth:sanctum ' ,
71+ RequireTwoFactorAuthentication::class,
72+ AuthenticateIPAccess::class,
7573 ],
7674 'application-api ' => [
7775 SubstituteBindings::class,
78- 'api..key: ' . ApiKey::TYPE_APPLICATION ,
7976 AuthenticateApplicationUser::class,
80- AuthenticateIPAccess::class,
81- ],
82- 'client-api ' => [
83- SubstituteClientBindings::class,
84- 'api..key: ' . ApiKey::TYPE_ACCOUNT ,
85- AuthenticateIPAccess::class,
86- // This is perhaps a little backwards with the Client API, but logically you'd be unable
87- // to create/get an API key without first enabling 2FA on the account, so I suppose in the
88- // end it makes sense.
89- //
90- // You just wouldn't be authenticating with the API by providing a 2FA token.
91- RequireTwoFactorAuthentication::class,
9277 ],
78+ // TODO: don't allow an application key to use the client API, but do allow a client
79+ // api key to access the application API.
80+ 'client-api ' => [SubstituteClientBindings::class],
9381 'daemon ' => [
9482 SubstituteBindings::class,
9583 DaemonAuthenticate::class,
@@ -112,7 +100,5 @@ class Kernel extends HttpKernel
112100 'bindings ' => SubstituteBindings::class,
113101 'recaptcha ' => VerifyReCaptcha::class,
114102 'node.maintenance ' => MaintenanceMiddleware::class,
115- // API Specific Middleware
116- 'api..key ' => AuthenticateKey::class,
117103 ];
118104}
0 commit comments