Add support for forward proxy auth. Tested with authentik.

- adds new method (`getUserFromProxyAuth) to server/Auth.js to check for
  relevant environment variables and pull the user from the request headers..
 - adds `/forwardauth` route to call new proxy auth method
 - modified /client/login.vue to call `/forwardauth` and authenticate
  the user if returned by forwardauth
 - add a helper method in `server/utils/parseBool.js` to help check for
  boolean values from environment
 - update the readme.md to explain how enable forward auth.
This commit is contained in:
pgodwin 2022-11-02 22:03:06 +10:00
parent 765a11f135
commit b8d0395e6d
5 changed files with 111 additions and 0 deletions

View file

@ -261,6 +261,14 @@ Middleware relating to CORS will cause the app to report Unknown Error when logg
From [@Dondochaka](https://discord.com/channels/942908292873723984/942914154254176257/945074590374318170) and [@BeastleeUK](https://discord.com/channels/942908292873723984/942914154254176257/970366039294611506)
<br />
### Forward Proxy Authentication
Users can be authenticated via an external proxy such as Authentik.
To use forward authentication you need to set the following environment variables:
* `PROXY_FORWARD_AUTH_ENABLED` - enable/disable forward authentication
* `PROXY_FORWARD_AUTH_USERNAME` - the name of the header containing the authenticated user's username. For example, by default in Authentik the value would be `X-authentik-username`.
* `PROXY_FORWARD_AUTH_CREATE` - automatically create users if they don't exist.
# Run from source
[See discussion](https://github.com/advplyr/audiobookshelf/discussions/259#discussioncomment-1869729)