auth selection: cookie with optional domain parameter

This commit is contained in:
Helmut Merz 2026-03-10 17:27:45 +01:00
parent a548575704
commit bf954a9614
2 changed files with 6 additions and 1 deletions

View file

@ -49,6 +49,10 @@ class LoginPageSelect(LoginPage):
def showSelection(self):
return getConfigAuthMethod() == 'cookie'
def authMethodCookieString(self):
domain = getattr(config, 'authentication_method_cookie_domain', None)
return 'document.cookie=`loops_auth_method=${this.value}; path=/; expires=Sun, 31 Jan 2027 12:00:00 UTC%s`' % (domain and f'; domain={domain}' or '')
def getConfigAuthMethod():
return getattr(config, 'authentication_method', 'legacy')

View file

@ -31,7 +31,8 @@
<select name="auth_method"
onchange="document.cookie=`loops_auth_method=${this.value}; path=/; expires=Sun, 31 Jan 2027 12:00:00 UTC`"
tal:define="meth view/authMethod"
tal:attributes="value meth">
tal:attributes="value meth;
onchange view/authMethodCookieString">
<option value="legacy" i18n:translate="authentication-method-legacy"
tal:attributes="selected python:meth=='legacy'">Legacy</option>
<option value="oidc" i18n:translate="authentication-method-oidc"