Files
wekan/docs/Features/Login/SAML.md
T
Lauri Ojansivu d6503b43f5 Choose which SAML signatures are required and log in by full-page redirect.
SAML 2.0 lets an identity provider sign the Response, the Assertion or
both. WeKan always required a signed Response (node-saml's default, never
overridden), so an identity provider that signs only the Assertion was
rejected with "Invalid document signature" before the Assertion was
checked. Admin Panel -> People -> SAML now has SAML_IDP_PROFILE: standard,
which keeps the previous behaviour, or signed-assertion-redirect, which
requires the Assertion signature instead and logs in by full-page redirect.
SAML_WANT_RESPONSE_SIGNED, SAML_WANT_ASSERTIONS_SIGNED and SAML_LOGIN_FLOW
can each be set on their own; left at Default they follow the profile. A
configuration requiring neither signature is refused, and validation
errors now reach the administrator instead of "Internal server error".

In redirect mode the ACS stores the validated profile under the random
credential token and redirects to /sign-in?samlToken=; the page exchanges
it and opens /. The assertion never enters the address. The token is
remembered in the tab that started the login, and a samlToken that tab did
not start is not exchanged, so a link cannot sign a browser into another
account. Errors return as samlError and are shown on the sign-in page.

A test signs responses with a throwaway key and runs them through the
shipped node-saml; browser tests log in through the fixture identity
provider in both flows. The new message is English, pending Transifex.

Thanks to xet7 !
2026-09-29 13:57:51 +03:00

9.7 KiB

How to enable it

WeKan has SP-initiated SAML 2.0 login, built on the actively-maintained, MIT-licensed @node-saml/node-saml library (it does all SAML protocol / XML-signature handling; WeKan only wires it into Meteor's accounts system - see the wekan-accounts-saml package under packages/wekan-accounts-saml/).

Enable it with these environment variables (see the commented example in docker-compose.yml):

Variable Meaning
SAML_ENABLED Set to true to show the "Sign In with SAML" button.
SAML_PROVIDER Short name for the identity provider; used in the ACS/callback URL.
SAML_ENTRYPOINT The identity provider's SSO redirect endpoint.
SAML_ISSUER This WeKan instance's SAML issuer / entity ID.
SAML_CERT The identity provider's signing certificate, used to verify the response signature.
SAML_IDPSLO_REDIRECTURL The identity provider's Single Logout redirect URL, if used.
SAML_PRIVATE_KEYFILE / SAML_PUBLIC_CERTFILE Paths under private/ to this instance's own key/cert, only needed if the IdP requires signed AuthnRequests.
SAML_IDENTIFIER_FORMAT NameID format requested from the IdP. Defaults to urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress.
SAML_LOCAL_PROFILE_MATCH_ATTRIBUTE Assertion attribute to use as the WeKan username instead of the NameID/email.
SAML_ATTRIBUTES Assertion attributes read for the local profile.
SAML_IDP_PROFILE What the identity provider signs and how login opens: standard (default) or signed-assertion-redirect. See below.
SAML_WANT_RESPONSE_SIGNED true/false: require a signed SAML Response. Default: from the profile.
SAML_WANT_ASSERTIONS_SIGNED true/false: require a signed Assertion. Default: from the profile.
SAML_LOGIN_FLOW popup or redirect. Default: from the profile.

The client opens a popup at /_saml/authorize, which redirects to the identity provider (SAML_ENTRYPOINT); the IdP posts the signed assertion back to /_saml/validate (WeKan's Assertion Consumer Service URL - <WeKan URL>/_saml/validate/<SAML_PROVIDER>), which is registered as the service's callback URL with the IdP. This mirrors the existing CAS popup-based login flow (packages/wekan-accounts-cas).

Identity-provider profiles

SAML 2.0 lets an identity provider sign the whole Response, only the Assertion inside it, or both. Which one it does is a property of that identity provider, so WeKan has a profile for each common arrangement:

SAML_IDP_PROFILE Signed Response required Signed Assertion required Login
standard (default) yes no popup
signed-assertion-redirect no yes full-page redirect

Each of the three settings can also be chosen on its own in Admin Panel / People / SAML; one left at Default follows the profile, and the page shows SAML_IDP_PROFILE as its source. WeKan refuses a configuration that requires neither signature, because an unsigned assertion would then be accepted. node-saml verifies every signature that is present against SAML_CERT.

Symptoms that point here:

  • "Invalid document signature" right after the identity provider reports success: the Response is not signed but SAML_WANT_RESPONSE_SIGNED is on. If the Assertion is signed, use signed-assertion-redirect or turn off only SAML_WANT_RESPONSE_SIGNED and turn on SAML_WANT_ASSERTIONS_SIGNED.
  • "Invalid signature" after that: SAML_CERT is not the certificate whose key signed the Assertion. Paste that certificate's PEM, including the BEGIN and END lines.

With SAML_LOGIN_FLOW=redirect the browser leaves WeKan for the identity provider and returns in the same window: the ACS stores the validated profile under the random credential token and redirects to /sign-in?samlToken=<token>, which the page exchanges for a login and then opens /. The assertion is never put in the address. The token is remembered in the browser tab that started the login, and a samlToken that tab did not start is not exchanged, so a link cannot sign someone into another account. Errors return as /sign-in?samlError=<message> and are shown on the sign-in page.

Admin Panel overrides and logout

Site administrators can open Admin Panel / People / SAML at /admin/people/saml. The shared settings form shows environment variable names and the source of each effective value. Saved values override the environment; blank fields and the Default boolean choice restore environment/default values. Saving applies the configuration without a server restart. Disabling SAML removes its service configuration and prevents pending credentials from completing login.

The page lists the assertion consumer, logout callback and public metadata URLs. Register /_saml/config/<SAML_PROVIDER> as the metadata endpoint where supported. When SAML_IDPSLO_REDIRECTURL is configured, signing out a SAML user first obtains a logout request, ends the local session, then navigates to the identity provider. The callback accepts validated logout responses; IdP-initiated logout requests are not supported. Protocol validation uses the existing MIT-licensed node-saml library. Metadata contains no private keys.

SAML_MERGE_EXISTING_USERS defaults to false. Enabling it allows SAML identities to match existing non-SAML usernames, so use it only with a trusted, controlled identity mapping. Its Admin Panel override follows the same precedence rules.

Configuration and route tests and Chromium settings tests cover this integration. End-to-end interoperability with a live identity provider still requires testing.

Popup closes but sign-in does not finish

A successful IdP response still needs to pass WeKan validation and establish a Meteor session. The response replay guard reads node-saml's string property profile.inResponseTo; it must not call a nonexistent getInResponseTo() method. The verified ID is consumed once. Missing IDs and replays remain rejected, and validateInResponseTo stays always.

If the ACS rejects a response, the popup's error marker now passes its message to the sign-in page. No credential exchange is attempted for that failed response. Error text is rendered as text, and cleared before the next attempt.

For an IdP that supplies a short account name in the username attribute and an email address separately, set SAML_LOCAL_PROFILE_MATCH_ATTRIBUTE=username. Enable SAML_MERGE_EXISTING_USERS only when intentionally linking the trusted IdP identity to an existing local account; the default remains false. Keep the client's public.SAML_PROVIDER consistent with the server's provider setting. Verify the issuer/audience, ACS URL and assertion-signing public certificate. A signature failure is distinct from a response-ID or account-conflict failure.

These are deployment-specific settings, not defaults changed by the fix. The local signed-response fixture and popup/UI tests do not validate a remote installation's certificate, account mapping or IdP configuration.

Sandstorm has SAML login, and old WeKan that will be updated someday:

How SAML works:

Ruby on Rails OmniAuth, that has Shibboleth and SAML:

The SSO Wall of Shame:

SAML Issue

SAML settings commit

The maintained implementation is in packages/wekan-accounts-saml/; configuration is in server/saml.js and models/lib/samlConfig.js.

Gitea

Laravel

ruby-saml/omniauth/RoR: Sign in as anyone: Bypassing SAML SSO authentication with parser differentials

Integration tests

See local login protocol tests for example identities, actual request/response checks, failure cases and deployment limitations.

Request correlation and replay protection

SAML login must start from WeKan's sign-in button. Responses require a live InResponseTo request ID; unsolicited IdP-initiated assertions and replayed responses are rejected. Signed responses still undergo node-saml signature, time and audience checks. Authentication requests and replay protection are process-local, so clustered instances require sticky routing for the login handshake. See the authentication boundary audit.