-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Support for authentication via header would be a great low-cost addition to Bookstack. With this authentication mode, Bookstack would check for the request header X-Webauth-User
, and attempt to log-in as that user automatically with no password/token. This mode leverages an external service, the auth proxy, to authenticate users and add the header. Sessions are stored externally also; the user remains logged-in while the header is present.
Louketo is a good example auth proxy that supports OIDC providers, like Keycloak, Dex, etc.
Grafana has an authentication module that works in this way.
To be clear, I am planning to make a pull request to add these features. It would be great to get some feedback on the plan first though!
How it works
The login flow looks like:
- User visits
bookstack.example.com
- The request comes through to an auth proxy, not Bookstack. For example:
- Nginx configured with Basic Auth, or
- Louketo, connected to an external OIDC IdP like Keycloak.
- The auth proxy authenticates the user (via a login page, an SSO token, etc)
- The auth proxy adds/populates the
X-Webauth-User
header, and proxies the request to Bookstack. - Bookstack sees the header, trusts the auth proxy, and logs the user in automatically.
- User is redirected to the application, skipping the login page.
A variety of auth proxies can be used to authenticate and set the header, for example: Basic Auth, vouch proxy, oauth2-proxy.
Benefits
- Allows a variety of authn services to be used; e.g. Keycloak supports almost any OIDC provider.
- Allows sessions to be managed externally (useful for strict security policies).
- Allows seamless SSO; users only presented with login page once, then have immediate access to other applications.
- Highly secure; leveraging an auth proxy project whose sole focus is on security.
- Easy to implement; minimal code to get it working.
- The Keycloak/Louketo setup is popular in Kubernetes, and would allow Bookstack to fit into existing setups very nicely.
- Permissions still handled within Bookstack; the auth proxy only handles authentication.
Considerations
LDAP: It would be very useful if LDAP Group Sync could continue working. When a user visits Bookstack, they should be authenticated via auth proxy, but their user info (and groups) could still come from LDAP sync.
Documentation: It is very important that users are not able to forge the X-Webauth-User
header as it allows passwordless login to any account. It is also important that users (either via web, or CLI on the server hosting Bookstack) are not able to bypass the auth proxy. There should be a dedicated section in the docs about protecting that header in Nginx, Apache, etc.
Logout: Logging-out can be handled in many different ways, depending on the auth proxy. The Logout
button in the Bookstack UI should be configurable to provide maximum flexibility.
Configuration: Some extra configuration options will be needed:
- User auth header (configure which header is used to pass the username/email to Bookstack).
- User auth field (does the header refer to username, or email?).
- Proxy IP whitelist (restrict incoming connections to a list of IPs, to ensure users can't bypass the auth proxy).
- Auto sing-up (if the user doesn't exist, should they be signed up? not applicable if LDAP sync is being used).
- Signup group (add new sign-ups to this group? again, not applicable for LDAP sync).