saml-auth
Authenticates users with a SAML identity provider.
saml-authPriority 2598What it does
saml-auth signs people in at a SAML identity provider before their browser reaches the route's backend. The people live at the identity provider at IdP URI, not on a consumer. The gateway takes part as a service provider named by SP issuer, signs its requests with the SP private key and checks the provider's answers against the IdP certificate.
Login callback URI, Logout URI and Logout callback URI are paths of the route, /saml/callback for example, and not full addresses. Authentication explains callers who sign in at an identity provider.
When to use it
- The company's identity provider speaks SAML, and an internal web application behind the gateway should use the same sign-in as every other company application.
- A backend that has no sign-in of its own should be reached only by people the identity provider signed in.
- People sign out at one path of the route and land on a page of your choice, under Logout redirect URI.
Not for an OpenID Connect provider or bearer tokens on API calls — see openid-connect (Authenticates users against an OpenID Connect provider), a CAS server — see cas-auth (Authenticates users against a CAS server) or a directory name and password a program sends on every call — see ldap-auth (Authenticates consumers against an LDAP directory).
Set it up
Sign users in through your identity provider with SAML
Under Basics set IdP URI to https://idp.example.com/saml/sso, set IdP certificate to <certificate PEM>, set SP issuer to https://api.example.com/saml/metadata, set SP certificate to <certificate PEM>, set SP private key to <private key PEM>, set Secret to <secret>, set Login callback URI to /saml/callback, set Logout URI to /saml/logout, set Logout callback URI to /saml/logout/callback and set Logout redirect URI to https://www.example.com/signed-out. Under Behavior fill IdP issuers as in the JSON below and set Replay dictionary to plugin-saml-auth-replay.
{
"idp_uri": "https://idp.example.com/saml/sso",
"idp_cert": "<certificate PEM>",
"idp_issuers": [
"https://idp.example.com/saml/metadata"
],
"sp_issuer": "https://api.example.com/saml/metadata",
"sp_cert": "<certificate PEM>",
"sp_private_key": "<private key PEM>",
"secret": "<secret>",
"replay_dict": "plugin-saml-auth-replay",
"login_callback_uri": "/saml/callback",
"logout_uri": "/saml/logout",
"logout_callback_uri": "/saml/logout/callback",
"logout_redirect_uri": "https://www.example.com/signed-out"
}
Things to know
- SP private key — The authentication request is signed with RSA-SHA512, so an elliptic-curve key is stored and then answers 500 on every request.
- Logout URI — Write a path on this route, such as /saml/logout: a full URL never matches and the request goes to the identity provider. Requests to it never reach the upstream; without a session cookie they get 401.
- Logout URI — An address that starts with
//,//idp.example.com/logoutfor example, is refused when you save. - Login callback URI — A full address in place of a path is refused when you save.
- Logout callback URI — A full address in place of a path is refused when you save.
- Secret — A secret shorter than
8characters is refused when you save. - Auth protocol binding method — With
HTTP-POSTthe session cookie is also marked Secure andSameSite=None. - Auth protocol binding method — Only
HTTP-POSTandHTTP-Redirectcan be set;HTTP-Artifactis refused when you save. - Replay dictionary — Only
plugin-saml-auth-replaycan be set; a dictionary of any other name is refused when you save. - AdviceRegister the SP issuer and the Login callback URI at the identity provider exactly as they are written here, and serve the route over HTTPS only.
- On a consumer or a consumer group it runs only after the consumer has been identified by a credential; it does not identify the consumer itself.
Settings
The fields as the console shows them, section by section.
Basics
idp_uristringRequiredhttps://idp.example.com/saml/ssoidp_certstringRequiredsp_issuerstringRequiredsp_certstringRequiredsp_private_keystringRequiredSent to the engine and never shown again.
secretstringRequiredThe secret the session keys are derived from: a random value, the same on every node. Stored on the engine and shown only to roles that manage this object.
login_callback_uristringRequiredpattern
^(/(?!/)|[$]secret://.+|[$][Ee][Nn][Vv]://.+)logout_uristringRequiredpattern
^(/(?!/)|[$]secret://.+|[$][Ee][Nn][Vv]://.+)logout_callback_uristringRequiredpattern
^(/(?!/)|[$]secret://.+|[$][Ee][Nn][Vv]://.+)logout_redirect_uristringRequiredBehavior
auth_protocol_binding_methodstringdefault HTTP-RedirectHow the identity provider carries its answer back to the login callback. HTTP-POST also makes the session cookie Secure and SameSite=None, and this form has no separate switches for either.
idp_issuersarray of stringsIssuers an assertion may come from; unset accepts any, an empty list accepts none.
sp_audiencesarray of stringsAudiences an assertion must name; unset, the SP issuer is expected.
clock_skewnumberTolerated clock difference with the identity provider; unset, a minute.
replay_dictstringRecords accepted assertions on this node so none is accepted twice; the one dictionary the engine declares. Not set, a one-time assertion is accepted and only logged.
Advanced
secret_fallbacksarray of stringsOlder secrets a cookie may still be signed with while a new one rolls out. Stored on the engine and shown only to roles that manage this object.
replay_ttlnumberHow long an assertion without an expiry of its own stays recorded; read only with a replay dictionary, and unset means ten minutes.
sp_acs_urlstringThe absolute external address of the assertion consumer; unset, it is derived from the request.
pattern
^https?://