misc_pterodactyl-panel/app/Http/Middleware/Api
Dane Everitt 60eff40a0c
Fix session management on client API requests; closes #3727
Versions of Pterodactyl prior to 1.6.3 used a different throttle pathway for
requests. That pathway found the current request user before continuing on to
other in-app middleware, thus the user was available downstream.

Changes introduced in 1.6.3 changed the throttler logic, therefore removing this
step. As a result, the client API could not always get the currently authenticated
user when cookies were used (aka, requests from the Panel UI, and not API directly).

This change corrects the logic to get the session setup correctly before falling
through to authenticating as a user using the API key. If a cookie is present and a
user is found as a result that session will be used. If an API key is provided it is
ignored when a cookie is also present.

In order to keep the API stateless any session created for an API request stemming
from an API key will have the associated session deleted at the end of the request,
and the 'Set-Cookies' header will be stripped from the response.
2021-11-03 20:51:39 -07:00
..
Application Use more standardized phpcs 2021-01-23 12:33:34 -08:00
Client Simplify logic when a server is in an unsupported state 2021-01-30 13:28:31 -08:00
Daemon Fix 401 error typo (#3393) 2021-06-03 13:35:51 -07:00
ApiSubstituteBindings.php Use more standardized phpcs 2021-01-23 12:33:34 -08:00
AuthenticateIPAccess.php Use more standardized phpcs 2021-01-23 12:33:34 -08:00
AuthenticateKey.php Fix session management on client API requests; closes #3727 2021-11-03 20:51:39 -07:00
HandleStatelessRequest.php Fix session management on client API requests; closes #3727 2021-11-03 20:51:39 -07:00
IsValidJson.php Use more standardized phpcs 2021-01-23 12:33:34 -08:00