diff --git a/plugins/lookup/sso.py b/plugins/lookup/sso.py index 98455fb33d..3aa8dfd9f5 100644 --- a/plugins/lookup/sso.py +++ b/plugins/lookup/sso.py @@ -8,6 +8,8 @@ API (STRICT): - {{ lookup('sso', application_id, 'flavor') }} → str - {{ lookup('sso', application_id, 'enabled') }} → bool - {{ lookup('sso', application_id, 'shared') }} → bool + - {{ lookup('sso', application_id, 'logout_url') }} → str, oauth2-proxy + sign-out wrapping OIDC.CLIENT.LOGOUT_URL when the app is proxy-gated Wraps ``utils.roles.applications.services.sso.get_sso_config`` so templates and tasks share one source of truth with Python callers @@ -22,7 +24,7 @@ from ansible.errors import AnsibleError from ansible.plugins.loader import lookup_loader from ansible.plugins.lookup import LookupBase -from utils.roles.applications.services.sso import get_sso_config +from utils.roles.applications.services.sso import get_sso_config, logout_url class LookupModule(LookupBase): @@ -51,6 +53,17 @@ class LookupModule(LookupBase): resolved = get_sso_config(applications, application_id) + if want == "logout_url": + if "OIDC" not in vars_: + raise AnsibleError( + "sso: 'logout_url' needs OIDC in the templating context" + ) + oidc = self._templar.template(vars_["OIDC"]) + return [ + logout_url( + str(oidc["CLIENT"]["LOGOUT_URL"]), bool(resolved["is_proxy_gated"]) + ) + ] if want == "all": return [resolved] if want not in resolved: diff --git a/roles/web-app-baserow/templates/javascript.js.j2 b/roles/web-app-baserow/templates/javascript.js.j2 index a8b83f405e..8f947dae32 100644 --- a/roles/web-app-baserow/templates/javascript.js.j2 +++ b/roles/web-app-baserow/templates/javascript.js.j2 @@ -1,5 +1,5 @@ (function () { - const LOGOUT_URL = {{ (('/oauth2/sign_out?rd=' ~ (OIDC.CLIENT.LOGOUT_URL | urlencode)) if (lookup('sso', application_id, 'is_proxy_gated') | bool) else OIDC.CLIENT.LOGOUT_URL) | to_json }}; + const LOGOUT_URL = {{ lookup('sso', application_id, 'logout_url') | to_json }}; const INJECTED_ATTR = "data-injected-logout"; const LOGOUT_SVG = '