Allowing full host override (#143)
This commit is contained in:
parent
89a90f4924
commit
40df900dc7
2 changed files with 11 additions and 2 deletions
|
@ -98,6 +98,8 @@ need to change this.
|
|||
|
||||
``REDIS_PREFIX``: (optional, defaults to ``"snappass"``) prefix used on redis keys to prevent collisions with other potential clients
|
||||
|
||||
``HOST_OVERRIDE``: (optional) Used to override the base URL if the app is unaware. Useful when running behind reverse proxies like an identity-aware SSO. Example: ``sub.domain.com``
|
||||
|
||||
Docker
|
||||
------
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ from distutils.util import strtobool
|
|||
|
||||
NO_SSL = bool(strtobool(os.environ.get('NO_SSL', 'False')))
|
||||
URL_PREFIX = os.environ.get('URL_PREFIX', None)
|
||||
HOST_OVERRIDE = os.environ.get('HOST_OVERRIDE', None)
|
||||
TOKEN_SEPARATOR = '~'
|
||||
|
||||
|
||||
|
@ -164,9 +165,15 @@ def handle_password():
|
|||
token = set_password(password, ttl)
|
||||
|
||||
if NO_SSL:
|
||||
base_url = request.url_root
|
||||
if HOST_OVERRIDE:
|
||||
base_url = f'http://{HOST_OVERRIDE}/'
|
||||
else:
|
||||
base_url = request.url_root
|
||||
else:
|
||||
base_url = request.url_root.replace("http://", "https://")
|
||||
if HOST_OVERRIDE:
|
||||
base_url = f'https://{HOST_OVERRIDE}/'
|
||||
else:
|
||||
base_url = request.url_root.replace("http://", "https://")
|
||||
if URL_PREFIX:
|
||||
base_url = base_url + URL_PREFIX.strip("/") + "/"
|
||||
link = base_url + url_quote_plus(token)
|
||||
|
|
Loading…
Reference in a new issue