Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug-landing-page #493

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ SITE_APP_CONFIG="./well-known/default-settings"
APP_TEMPLATE="sample"
APP_LOGINMETHOD="standard-widget"
APP_NAME="Sample App"
# set this variable to a local page of the app
# e.g. profile, index
APP_POST_LOGIN_LANDING_URL=""
# set this variable to redirect to an absolute URL after login
# e.g. https://someother.web.app/
APP_POST_LOGIN_OVERRIDE_LANDING_URL=""
APP_SLOGAN=""
APP_SUBSLOGAN=""
APP_LOGO=""
Expand Down
18 changes: 8 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import logging.config
import re

from flask import Flask, send_from_directory, render_template
from flask import request, session, make_response, redirect
Expand Down Expand Up @@ -219,17 +220,15 @@ def oidc_callback_handler():

def get_post_login_landing_page_url():
logger.debug("get_post_login_landing_page_url()")
app_landing_page_url = ""
session_settings = session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]
app_landing_page_override_url = session_settings["app_post_login_override_landing_url"]

# Pull from Config
hosturl = request.host_url.replace("http://", "{0}://".format(session[SESSION_INSTANCE_SETTINGS_KEY]["app_scheme"]))

if session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_post_login_landing_url"]:
app_landing_page_url = hosturl + "{app_template}/{landing_page}".format(
app_template=session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_template"],
landing_page=session[SESSION_INSTANCE_SETTINGS_KEY]["settings"]["app_post_login_landing_url"],)
# if the configured value is a full URL, then use it, don't try to build one
if re.match(r"^http[s]?://", app_landing_page_override_url):
app_landing_page_url = app_landing_page_override_url
else:
app_landing_page_url = hosturl + "profile"
landing_page = session_settings["app_post_login_landing_url"]
app_landing_page_url = "{0}{1}".format(request.host_url, landing_page)

# Check for from_uri key, this always overrides the config
if FROM_URI_KEY in session:
Expand All @@ -238,7 +237,6 @@ def get_post_login_landing_page_url():
session[FROM_URI_KEY] = ""

logger.debug("app landing page {0}".format(app_landing_page_url))

return app_landing_page_url


Expand Down
1 change: 1 addition & 0 deletions config/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def get_app_version():
"settings": {
"app_template": os.getenv("APP_TEMPLATE", "sample"),
"app_post_login_landing_url": os.getenv("APP_POST_LOGIN_LANDING_URL", "profile"),
"app_post_login_override_landing_url": os.getenv("APP_POST_LOGIN_OVERRIDE_LANDING_URL", ""),
"app_loginmethod": os.getenv("APP_LOGINMETHOD", "standard-widget"),
"app_name": os.getenv("APP_NAME", "Sample App"),
"app_slogan": os.getenv("APP_SLOGAN", ""),
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ The `.env` file provides additional configuration depending on the functionality
| APP_TEMPLATE | Enter the specific value based on the [vertical](#vertical-specific-variables) | |
| APP_LOGINMETHOD | The login UX, widget, custom or redirect | Options: `standard-widget`, `passwordless-widget`,`custom-widget`
| APP_NAME | some app name prominently displayed | |
| APP_POST_LOGIN_LANDING_URL | local page to redirect to after login | profile |
| APP_POST_LOGIN_OVERRIDE_LANDING_URL | absolute URL to redirect to after login | https://okta.com |
| APP_SLOGAN | some slogan | |
| APP_SUBSLOGAN | some subtitle | |
| APP_LOGO | url to some logo | |
Expand Down