Skip to content

Conversation

@eyJhb
Copy link
Contributor

@eyJhb eyJhb commented Jan 2, 2025

Useful if you have authentication in front of wger, and want to use that instead of wgers authentication/signup methods.

Proposed Changes

Added a new setting, which can be used to setup proxy auth header, e.g. using Authelia to authenticate + create users on the instance.

Fixes #1847 , and potential VERY SIMPLE solution for #1805 ( #1797 )

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Added yourself to AUTHORS.rst

Other questions

  • Do users need to run some commmands in their local instances due to this PR
    (e.g. database migration)? No

Remaining work

  • Add to documentation.
  • Flutter needs to support setting API key, instead of username/password.

@eyJhb eyJhb force-pushed the proxyauthheader branch 4 times, most recently from 714efe6 to 2a306f4 Compare January 2, 2025 11:43
@eyJhb eyJhb changed the title adds support for proxy auth header adds support for auth proxy header Jan 2, 2025
@eyJhb eyJhb force-pushed the proxyauthheader branch 2 times, most recently from d46d469 to 7a7a494 Compare January 2, 2025 12:10
Useful if you have authentication in front of wger, and want to use
that instead of wgers authentication/signup methods.
@eyJhb
Copy link
Contributor Author

eyJhb commented Jan 2, 2025

Maybe this should only be checked for / like in Miniflux here 1pav/miniflux@5a40096 , but I'm unsure what would be best tbh.

@rolandgeider
Copy link
Member

BTW I haven't forgotte about this PR, but since it would add a new auth method I'd like to make sure we do it right. I've added this to the 2.4 backlog (so after the flexible routines get merged)

@rolandgeider rolandgeider moved this to Backlog in Release 2.4 Mar 11, 2025
@rolandgeider rolandgeider requested a review from Copilot April 17, 2025 16:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for authentication via a proxy header by introducing new settings, middleware, and an authentication backend, along with tests to verify the feature.

  • Added new settings and middleware in wger/settings_global.py to support proxy-based authentication.
  • Introduced AuthProxyHeaderMiddleware and AuthProxyUserBackend in wger/core to authenticate users based on a trusted header.
  • Added comprehensive tests in wger/core/tests to validate the auth proxy behavior and updated the production settings.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wger/settings_global.py Added new settings and registered the auth proxy middleware and backend.
wger/settings.tpl Documented usage of the auth proxy header setting.
wger/core/tests/test_auch_proxy_middleware.py Added tests covering various auth proxy scenarios.
wger/core/middleware.py Introduced middleware to authenticate users via a trusted proxy header.
wger/core/backends.py Implemented a custom backend for proxy header-based authentication.
extras/docker/production/settings.py Configured the necessary auth proxy settings for the production environment.
Comments suppressed due to low confidence (1)

wger/core/tests/test_auch_proxy_middleware.py:1

  • [nitpick] The file name 'test_auch_proxy_middleware.py' appears to have a typo; consider renaming it to 'test_auth_proxy_middleware.py' for clarity.
# This file is part of wger Workout Manager.

Had the guest user option deactivated in the dev-settings
We now properly redirect logged-out users to the login page, instead of only
showing a permission denied error. If a user is already logged in, and they visit
the page, they are redirected to the url in "next". We also now only apply
the auth header checks there.
This allows setting directly these values for new users created through
the auth proxy.
Otherwise, it is possible to land on the login page being logged-in, but
having to do a reload first to actually being redirected to the dashboard.
@rolandgeider rolandgeider merged commit bce70be into wger-project:master May 11, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Proxy Auth via. HTTP header

2 participants