From 8742015f4581fdcc719567b86c14cf21d337f6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20M=C3=A9doc?= Date: Wed, 4 Dec 2024 03:10:58 +0100 Subject: [PATCH] Header authentication (#180) * Use BaseSetting for default group * Add header authentication * Add instructions for proxy auth * Global flag to enable header authentication * First user goes to setup-wizard regardless of proxy auth * Update readme regarding proxy authentication * Add function for creating a user * Fix issue with bolean value of HEADER_AUTH_ENABLED * Disable password change for proxy users * format code * fix lint errors * Default value for proxy headers * Ensure HEADER_USERNAME is set when using proxy auth * Add error logging for header authentication --- README.md | 16 +++++ .../admin/SettingsForm/DefaultGroup.svelte | 1 - src/lib/server/user.ts | 71 +++++++++++++++++++ src/routes/account/+page.server.ts | 11 ++- src/routes/account/+page.svelte | 6 +- src/routes/login/+page.server.ts | 68 ++++++++++++++++-- src/routes/signup/+page.server.ts | 69 +++--------------- 7 files changed, 174 insertions(+), 68 deletions(-) create mode 100644 src/lib/server/user.ts diff --git a/README.md b/README.md index 1040394..7a45d01 100644 --- a/README.md +++ b/README.md @@ -127,3 +127,19 @@ In this mode, the suggested item is automatically approved and added to the wish ### SMTP SMTP does not need to be configured for the app to function. SMTP enables inviting users via email and the forgot password flow. Without SMTP, you can still manually generate invite links and forgot password links. + +### Proxy authentication + +> [!WARNING] +> When header authentication is enabled, Wishlist makes no assumptions about the validity of the headers. It is up to you to have your proxy properly configured. An improperly configured proxy **could allow anyone** to gain access to the application by forging the headers. + +If you have a reverse proxy you want to use to login your users, you do it via our proxy authentication method. To configure this method, your proxy must send HTTP headers containing the name, username and email for the logged in user. +You configure this using environment variables. + +`HEADER_AUTH`: Enable proxy authentication + +`HEADER_USERNAME`: The name of the headers that contains the username of the user + +`HEADER_NAME`: The name of the headers that contains the full name of the user + +`HEADER_EMAIL`: The name of the headers that contains the email of the user diff --git a/src/lib/components/admin/SettingsForm/DefaultGroup.svelte b/src/lib/components/admin/SettingsForm/DefaultGroup.svelte index fe8f729..8266eb0 100644 --- a/src/lib/components/admin/SettingsForm/DefaultGroup.svelte +++ b/src/lib/components/admin/SettingsForm/DefaultGroup.svelte @@ -1,6 +1,5 @@