Zum Inhalt springen

SAML 2.0

OkYouIn is a SAML 2.0 identity provider (IdP) for applications that expect one. SAML applications share the sign-in page and the session with OpenID Connect: a user signed in to GitLab over OIDC opens Nextcloud over SAML without a second prompt.

Step-by-step setups: GitLab, Nextcloud, FortiGate admin GUI. Templates for Microsoft 365, Google Workspace, Palo Alto GlobalProtect and any SAML service provider exist but are not verified in our lab yet.

  • The server’s public URL (Settings ▸ General) must be https://. It is part of every IdP URL; without it every /saml/ endpoint answers 503.
  • The service provider (SP) must receive the response on an https ACS URL (http only for localhost, 127.0.0.1 and [::1]).

Every SAML application gets a SAML slug, generated from its name when it is created and fixed afterwards. It is part of the IdP entity ID and of every URL the SP uses. For an application with the slug nextcloud on https://mfa.example.com:

WhatURL
IdP entity ID (Issuer)https://mfa.example.com/saml/nextcloud
Metadatahttps://mfa.example.com/saml/nextcloud/metadata
Single sign-on service (Redirect and POST)https://mfa.example.com/saml/nextcloud/sso
Single logout service (Redirect and POST)https://mfa.example.com/saml/nextcloud/slo
Signing certificatehttps://mfa.example.com/saml/nextcloud/certificate.pem
Next certificate (during a rotation)https://mfa.example.com/saml/nextcloud/certificate.pem?which=next
IdP-initiated starthttps://mfa.example.com/saml/nextcloud/start

The Connect tab shows the same values for your server, a Download metadata button and the certificate. Give the SP the metadata, or the URLs and the certificate.

Sign-inSP-initiated: AuthnRequest over HTTP-Redirect or HTTP-POST; the Response always over HTTP-POST
IdP-initiatedOptional, per application (off by default)
SigningResponse, assertion or both; RSA or ECDSA with SHA-256 (never SHA-1)
Signed requestsVerified when the SP signs them; can be required
Single logoutSP-initiated, HTTP-Redirect or HTTP-POST
SP metadataImported from an XML file or pasted XML

Not supported: the Artifact binding, encrypted assertions or NameIDs, SOAP or back-channel logout, IdP-initiated or propagated logout, fetching metadata from a URL, and arbitrary directory attributes or value transformations as attribute sources.

The application’s Settings tab has four cards.

SettingMeaning
SP Entity IDThe SP’s entity ID; every AuthnRequest must carry exactly this Issuer.
ACS endpointsThe SP’s Assertion Consumer Service URLs (HTTP-POST) with an index; one may be the default. A request naming an ACS URL must match one byte for byte.
SP single logout URL and Logout bindingWhere the LogoutResponse goes (Redirect or POST).
SP certificatesThe certificate(s) the SP signs requests with (PEM, at most two during a rollover).
Require signed requestsRefuse unsigned AuthnRequests. Needs at least one SP certificate.

Import SP metadata fills this card from the SP’s metadata XML: entity ID, ACS endpoints, logout URL, certificates, whether it wants signed assertions, and its requested attributes (proposed as rows of the attribute table). Nothing is saved until you review the form and save. The metadata’s own signature is not checked.

SettingOptions
SignResponse and assertion (default) · Assertion only · Response only
Signing certificateGlobal certificate (recommended; shared by every SAML application on it) · Own certificate (this application’s own)

Choose what the SP requires. Many SPs accept either level; some (Nextcloud, FortiGate with require-signed-resp-and-asrt) want both.

NameID format: E-mail address, Persistent, Unspecified or Transient. NameID value decides what goes into it:

NameID valueContent
Opaque per-application IDA stable ID per application and user that cannot be linked across applications (the default for Persistent). Re-creating the application produces new IDs.
UsernameThe OkYouIn username
Username with domainusername@domain for directory users
E-mailThe user’s e-mail; a user without one is refused (nameid_missing)
OkYouIn user IDThe user’s UUID
objectGUID (base64, Microsoft ImmutableID)For Microsoft 365 federation; directory users only

A Transient NameID is new in every assertion.

The Attribute mapping table lists the SAML attributes the assertion carries, in order (at most 50):

ColumnValues
NameThe SAML attribute name
Name formatUnspecified, Basic or URI reference
Friendly nameOptional, meaningful with URI names
ValueA user field — E-mail, Username, Username with domain, First name, Last name, Display name, Phone, OkYouIn user ID, objectGUID (text or base64), MFA claim (Microsoft multipleauthn) — or Groups, or a Constant
MultiFor groups and constants: one AttributeValue per value; off joins groups with commas

An attribute whose value is empty for a user is left out. Presets add common name sets: Microsoft claim URIs and OID (eduPerson).

Groups filter limits which groups are sent — one name per line, a name ending in * matches as a prefix, case-insensitive; empty = all groups.

Preview for a user shows the NameID and attributes this application would send a chosen user now, from the form as it is (unsaved changes included). Nothing is signed, sent or logged — the quickest way to check a mapping before the SP sees it.

Application rules can add attributes on top of the table: a rule attribute with a row’s exact name replaces the row. Template attributes a rule leaves out are sent with their default.

  • IdP-initiated sign-in and Default RelayState — see below.
  • Require MFA and Session lifetime (hours) — as for OIDC: how long one MFA serves this application.

SAML has no first-factor choice: the password is always checked by OkYouIn (or replaced by a Windows ticket).

  1. The SP sends an AuthnRequest to /saml/<slug>/sso. OkYouIn checks the Issuer, the signature (when present or required), the destination and the ACS URL. A request that fails these checks never produces a POST to an unverified address — the user sees an error page instead.

  2. Without a live OkYouIn session the user signs in on the sign-in page: password, then the second factor if the rules require it.

  3. OkYouIn posts the signed Response to the ACS URL. The assertion is valid for 5 minutes and names the SP as its audience.

  4. A denied or cancelled sign-in posts an error Response back to the SP, so the SP can show its own message.

The policy is evaluated on every request with the browser’s address, exactly as for OIDC.

With IdP-initiated sign-in on, opening https://mfa.example.com/saml/<slug>/start signs the user in and posts an unsolicited Response to the SP, with Default RelayState as the RelayState. It is off by default: unsolicited responses can be replayed at SPs that keep no one-time cache, and any web page can make a browser sign in to the SP. Turn it on only for SPs that need it. GitLab accepts it; Nextcloud’s user_saml and FortiGate refuse it.

Certificates live in slots: one global slot (Access ▸ Settings ▸ Single sign-on) and one per application that uses its own certificate (on the application’s Settings tab). Each slot holds certificates in three states:

StateMeaning
ActiveSigns every Response and assertion.
NextPrepared and already published in the metadata, but not signing yet.
RetiredReplaced; kept so that Revert can bring it back.

The global certificate is created at the first start of OkYouIn. Generated certificates are self-signed RSA 3072, valid for 3 years. You can also Upload your own (PEM or PKCS#12) or create a CSR and upload the certificate your CA issues.

  1. Prepare next — Generate, Upload or CSR. The new certificate is stored as Next and published in the metadata at once; the active one keeps signing.

  2. Give the next certificate to every SP that pins the certificate or its fingerprint (the Connect tab and certificate.pem?which=next serve it). SPs that read the metadata pick it up on their own.

  3. Activate next — the next certificate signs from now on and the active one becomes Retired.

  4. If an SP breaks, Revert — the newest retired certificate signs again and the current one goes back to next.

Rotation is never automatic: SPs that pin a certificate (FortiGate, GitLab with a fingerprint) would break silently. Each device guide says how its SP handles a rotation — GitLab can trust two certificates at once; Nextcloud and FortiGate hold exactly one and need the switch right after Activate next. Putting such an application on its own certificate keeps a rotation of the global one away from it.

Switching an application between the global and its own certificate takes effect when you save: the SP must trust the new one, or sign-ins fail. To switch without an outage, keep the application on the global certificate, prepare its own next certificate, give it to the SP, then Activate next — the application switches to its own certificate in the same step.

Every certificate in use raises an alert 60 days before it expires, escalated at 30 and 7 days, listing the affected applications and whether a next certificate is already prepared. An expired certificate keeps signing — most SPs ignore the validity of a pinned IdP certificate — so the alert is a warning, not an outage.

When the SP sends a LogoutRequest to /saml/<slug>/slo, OkYouIn ends the OkYouIn session and returns a LogoutResponse to the SP single logout URL. A signed request that matches the browser’s session ends it at once; an unsigned one first shows the “Sign out?” confirmation.

Every SAML sign-in and sign-out is in Logging ▸ SSO sign-in log.

SymptomLook at
Error page instead of the sign-inThe Issuer differs from SP Entity ID, the ACS URL is not registered (byte for byte), or the request is unsigned while Require signed requests is on.
SP says the signature is invalidThe SP holds another certificate — after a rotation, or after switching between global and own. Compare fingerprints on the Connect tab.
SP refuses the Response as unsignedSet Sign to Response and assertion.
nameid_missingThe NameID value is E-mail (or objectGUID) and the user has none.
SP creates a new account for an existing userThe NameID changed — another NameID value, or a re-created application with an opaque NameID.
Groups missingGroups filter, or the attribute is single-valued (Multi off). Check with Preview for a user.