Skip to content
Snippets Groups Projects
Commit 2703c51a authored by Art's avatar Art :lizard:
Browse files

Simplify development setup.

parent 760d49b0
Branches
No related tags found
No related merge requests found
...@@ -17,10 +17,12 @@ for setting_name in [k for k in globals().keys() if k.isupper()]: ...@@ -17,10 +17,12 @@ for setting_name in [k for k in globals().keys() if k.isupper()]:
# checks # checks
SSO_DISABLED = SSO_DISABLED or getattr(conf.settings, "IDP_IGNORE", False) # legacy config
if not SSO_DISABLED:
assert conf.settings.DEBUG, "Not ignoring IDP on production."
assert SP_HOST and SP_PORT, "Need SP_HOST and SP_PORT configured in settings." assert SP_HOST and SP_PORT, "Need SP_HOST and SP_PORT configured in settings."
assert not SP_HOST.lower().startswith(("http:", "https:",)), "Need host name without protocol and port." assert not SP_HOST.lower().startswith(("http:", "https:",)), "Need host name without protocol and port."
# helpers # helpers
_SET_ON_RUNTIME = None and "doesn't make sense to change it" _SET_ON_RUNTIME = None and "doesn't make sense to change it"
...@@ -41,6 +43,9 @@ def read_key(path): ...@@ -41,6 +43,9 @@ def read_key(path):
with open(path, "r") as f: with open(path, "r") as f:
return f.read() return f.read()
except FileNotFoundError: except FileNotFoundError:
if SSO_DISABLED:
return None
else:
raise FileNotFoundError("SSO requires a key pair. Missing: {path}".format(path=path)) raise FileNotFoundError("SSO requires a key pair. Missing: {path}".format(path=path))
......
...@@ -28,8 +28,8 @@ Settings you might want to change on development (don't change them for producti ...@@ -28,8 +28,8 @@ Settings you might want to change on development (don't change them for producti
""" """
# development helpers # development helpers
SSO_DISABLED = False
SP_FORCE_ENTITY_ID = None # do NOT set for production, set to some unique string on development SP_FORCE_ENTITY_ID = None # do NOT set for production, set to some unique string on development
IDP_IGNORE = False # ignore IDP entirely, SSO will not function
""" """
......
...@@ -13,9 +13,9 @@ class SSOAuthConfig(AppConfig): ...@@ -13,9 +13,9 @@ class SSOAuthConfig(AppConfig):
def ready(self, *args, **kwargs): def ready(self, *args, **kwargs):
super().ready(*args, **kwargs) super().ready(*args, **kwargs)
# OneLogin settings stuff # OneLogin settings stuff
if app_settings.IDP_IGNORE: if app_settings.SSO_DISABLED:
assert conf.settings.DEBUG, "And how should SSO work on production if you ignore the IDP?" assert conf.settings.DEBUG
logger.info("SSO will not work.") logger.debug("SSO is disabled.")
else: else:
try: try:
app_settings.ONELOGIN_SETTINGS = sso_utils.create_onelogin_settings(app_settings.ONELOGIN_SETTINGS_TEMPLATE) app_settings.ONELOGIN_SETTINGS = sso_utils.create_onelogin_settings(app_settings.ONELOGIN_SETTINGS_TEMPLATE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment