add env var ENABLE_DOMAIN_CHECKER

when using localhost and standalone idhub instance we could avoid this
checker to facilitate testing and deployment
This commit is contained in:
pedro 2025-01-08 22:34:34 +01:00
parent 4a0f234e6c
commit 76921a71c8
2 changed files with 11 additions and 8 deletions

View file

@ -33,10 +33,11 @@ class UserView(LoginRequiredMixin):
]
def get(self, request, *args, **kwargs):
err_txt = "User domain is {} which does not match server domain {}".format(
request.get_host(), settings.DOMAIN
)
assert request.get_host() == settings.DOMAIN, err_txt
if settings.ENABLE_DOMAIN_CHECKER:
err_txt = "User domain is {} which does not match server domain {}".format(
request.get_host(), settings.DOMAIN
)
assert request.get_host() == settings.DOMAIN, err_txt
self.admin_validated = cache.get("KEY_DIDS")
response = super().get(request, *args, **kwargs)
@ -55,10 +56,11 @@ class UserView(LoginRequiredMixin):
return url or response
def post(self, request, *args, **kwargs):
err_txt = "User domain is {} which does not match server domain {}".format(
request.get_host(), settings.DOMAIN
)
assert request.get_host() == settings.DOMAIN, err_txt
if settings.ENABLE_DOMAIN_CHECKER:
err_txt = "User domain is {} which does not match server domain {}".format(
request.get_host(), settings.DOMAIN
)
assert request.get_host() == settings.DOMAIN, err_txt
self.admin_validated = cache.get("KEY_DIDS")
response = super().post(request, *args, **kwargs)
url = self.check_gdpr()

View file

@ -240,5 +240,6 @@ OIDC_ORGS = config('OIDC_ORGS', '')
ENABLE_EMAIL = config('ENABLE_EMAIL', default=True, cast=bool)
CREATE_TEST_USERS = config('CREATE_TEST_USERS', default=False, cast=bool)
ENABLE_2FACTOR_AUTH = config('ENABLE_2FACTOR_AUTH', default=True, cast=bool)
ENABLE_DOMAIN_CHECKER = config('ENABLE_DOMAIN_CHECKER', default=True, cast=bool)
COMMIT = config('COMMIT', default='')