-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add header-based authentication support #5271
base: 1.0-develop
Are you sure you want to change the base?
Add header-based authentication support #5271
Conversation
This commit adds support for header-based authentication, allowing users to authenticate via HTTP headers. This is particularly useful for proxy authentication via SSO providers like Authelia or Authentik. Features:\n- New HeaderAuthentication middleware\n- Configurable header names for username and email\n- Optional automatic user creation\n- Comprehensive test suite\n- SQLite and MySQL compatibility The feature can be enabled via environment variables:\nAUTH_HEADER_ENABLED=true\nAUTH_HEADER_AUTO_CREATE=true\nAUTH_HEADER_USERNAME=X-Auth-Username\nAUTH_HEADER_EMAIL=X-Auth-Email
You have to exclude the api route from pterodactyl on your reverse proxy, to bypass the api route, otherwise youll get an error with: "Request header to big" |
Thanks for the feedback! You are right - I have updated the PR description to include recommended reverse proxy configuration. Users should exclude the For example, with Nginx: location /api {
proxy_pass http://panel:80;
# Do not add auth headers for API routes
}
location / {
proxy_pass http://panel:80;
# Add auth headers here
proxy_set_header X-Auth-Username $user;
proxy_set_header X-Auth-Email $email;
} This ensures API functionality remains unaffected while still allowing header authentication for the web interface. |
@@ -59,6 +59,7 @@ | |||
'api' => [ | |||
'driver' => 'token', | |||
'provider' => 'users', | |||
'hash' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious to the reasoning on setting hash
to false
here? I don't think that is part of this feature, and this seems to be the default value according to older Laravel docs:
https://laravel.com/docs/5.8/api-authentication#hashing-tokens
Maybe good to keep removed?
This PR adds support for header-based authentication, allowing users to authenticate via HTTP headers. This is particularly useful for proxy authentication via SSO providers like Authelia or Authentik.
Features:
The feature can be enabled via environment variables:
Reverse Proxy Configuration
When using this feature with a reverse proxy, it is important to exclude the /api route from header authentication to prevent issues with API requests. Here is an example Nginx configuration:
This implementation provides a simple way to integrate with existing SSO solutions without requiring complex LDAP, SAML, or OIDC implementations. The proxy handles the authentication, and the panel trusts the headers it receives.
All tests are passing, and the implementation is compatible with both MySQL and SQLite databases.
Fixes #4026