Files
wekan/server/models
Lauri Ojansivu 2e752c1e96 Extract the OIDC RP-Initiated Logout URL builder into a pure, tested helper.
#2905 asked for Single Logout (SLO): logging out of Wekan should also end the
identity provider's own SSO session for OIDC/OAuth2 providers that support
RP-Initiated Logout (e.g. Keycloak's
/realms/<realm>/protocol/openid-connect/logout), via the optional
OAUTH2_LOGOUT_ENDPOINT env var. This was already implemented for #6158
(getOauthLogoutUrl() in server/models/settings.js, wired into
config/accounts.js's onLogoutHook(), documented in
docs/Features/Login/Keycloak/Keycloak.md and the docker-compose.yml OAuth2
example blocks) - when unset (the default), logout is unchanged.

The URL-building logic lived inline in the Meteor method, so it had no direct
test coverage. Extracted it to server/lib/oauthLogoutUrl.js's
buildOauthLogoutUrl(), a plain-Node pure function (endpoint/serverUrl/
clientId/redirectUri in, the end_session URL out - or '' when endpoint is
unset), following the same pattern as server/lib/ldapPasswordLoginGuard.js.
getOauthLogoutUrl() now just calls it; behavior is unchanged.

Added tests/oauthLogoutUrl.test.cjs covering: the default no-op when
OAUTH2_LOGOUT_ENDPOINT is unset/empty, a Keycloak-shaped path endpoint
resolved against OAUTH2_SERVER_URL (with and without a trailing slash), an
absolute endpoint that ignores serverUrl, an endpoint that already carries a
query string, optional client_id/post_logout_redirect_uri, and percent-
encoding of the redirect URI.

Thanks to Dzordzu and xet7 !

Closes #2905,
2026-09-10 20:27:34 +03:00
..
2026-06-06 02:53:58 +03:00
2026-09-10 19:47:15 +03:00
2026-06-06 02:53:58 +03:00