Add support for authentication proxies (#321)

* add support for auth proxies

* Improve docs
This commit is contained in:
Sascha Ißbrücker
2022-08-14 13:35:03 +02:00
committed by GitHub
parent 1308370027
commit c9c6b097d0
5 changed files with 90 additions and 7 deletions

View File

@@ -182,3 +182,20 @@ MAX_ATTEMPTS = 5
# specced systems like Raspberries. Should be OK as tasks are not time critical.
BACKGROUND_TASK_RUN_ASYNC = True
BACKGROUND_TASK_ASYNC_THREADS = 2
# Enable authentication proxy support if configured
LD_ENABLE_AUTH_PROXY = os.getenv('LD_ENABLE_AUTH_PROXY', False) in (True, 'True', '1')
LD_AUTH_PROXY_USERNAME_HEADER = os.getenv('LD_AUTH_PROXY_USERNAME_HEADER', 'REMOTE_USER')
LD_AUTH_PROXY_LOGOUT_URL = os.getenv('LD_AUTH_PROXY_LOGOUT_URL', None)
if LD_ENABLE_AUTH_PROXY:
# Add middleware that automatically authenticates requests that have a known username
# in the LD_AUTH_PROXY_USERNAME_HEADER request header
MIDDLEWARE.append('bookmarks.middlewares.CustomRemoteUserMiddleware')
# Configure auth backend that does not require a password credential
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.RemoteUserBackend',
]
# Configure logout URL
if LD_AUTH_PROXY_LOGOUT_URL:
LOGOUT_REDIRECT_URL = LD_AUTH_PROXY_LOGOUT_URL