Skip to main content

Sign in to a SAML application

Use LumoAuth as the identity provider of an application that speaks SAML.

RecipeReadyView source
Works with
Plain HTTP
Standards
SAML 2.0

What it shows​

  1. You create a SAML application in the portal for the service provider "Acme Wiki", with its entity ID and its ACS URL.
  2. You give the service provider the metadata address of LumoAuth. A script prints the values that it asks for.
  3. A person opens the wiki. The wiki sends a sign-in request, the person signs in at LumoAuth, and the browser posts a signed response to the ACS URL.
  4. The assertion names the person by email address and carries the email address and the name as attributes.

Before you start​

  • A service provider that speaks SAML, with an https ACS URL on a public host. Its SAML settings give you two values: its entity ID and its ACS URL. In this page they are https://wiki.acme.example/saml/metadata and https://wiki.acme.example/saml/acs.
  • Check that your plan includes the SAML identity provider in the plans matrix.
  • An account in the portal that may create applications.

Create the application​

  1. In the portal, open Applications & developer tools, Applications, and select New application.
  2. Under Protocol, choose SAML 2.0.
  3. Enter Application name "Acme Wiki", the Entity ID (issuer) and the ACS URL of the service provider. Select Create application.
  4. The page of the application opens on the tab Identity provider. It shows the IdP metadata URL, the IdP entity ID, the SSO URL, the SLO URL and the signing certificate.
  5. On the tab Security, keep Sign SAML responses and Sign SAML assertions on. Edit also lets you choose the NameID format and the NameID source: the default is the email address of the user.
  6. In the SAML settings of the service provider, enter the IdP metadata URL. If it cannot read a metadata URL, enter the entity ID, the SSO URL and the certificate.
  7. Open the service provider in a private window, and start its sign-in. Sign in at LumoAuth. The service provider receives the response and shows the person as signed in.

These steps were followed on a LumoAuth organization. The portal steps were followed on an organization. A stand-in for the service provider sent the sign-in request, and its signed response was checked with the certificate of the metadata.

Code​

The script reads the metadata of your organization and prints the values that a service provider asks for. The metadata is public, so the script needs no API key.

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The portal steps were followed on an organization. A stand-in for the service provider sent the sign-in request, and its signed response was checked with the certificate of the metadata.

oauth/saml-application/http/idp-metadata.sh
#!/bin/sh
# Reads the SAML metadata of your organization, and prints the values that a
# service provider asks for, with curl.
#
# sh oauth/saml-application/http/idp-metadata.sh
#
# The script needs curl, xmllint and openssl. The metadata is public: no key.
set -eu

METADATA_URL="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/saml/idp/metadata"
METADATA=$(curl --silent --show-error --fail "$METADATA_URL")

# The XML uses namespaces, so the paths name each element by its local name.
value() { printf '%s' "$METADATA" | xmllint --xpath "string($1)" -; }
SSO='//*[local-name()="SingleSignOnService"]'
SLO='//*[local-name()="SingleLogoutService"]'

echo "metadata URL: $METADATA_URL"
echo "IdP entity ID: $(value '//*[local-name()="EntityDescriptor"]/@entityID')"
echo "SSO URL: $(value "$SSO[1]/@Location") (HTTP-Redirect and HTTP-POST)"
echo "SLO URL: $(value "$SLO[1]/@Location")"

# The certificate that the service provider uses to check the signatures.
CERTIFICATE=$(value '(//*[local-name()="X509Certificate"])[1]' | tr -d ' \n')
printf -- '-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----\n' "$CERTIFICATE" \
| fold -w 64 \
| openssl x509 -noout -enddate -fingerprint -sha256 \
| sed 's/^notAfter=/certificate expires: /; s/^sha256 Fingerprint=/certificate SHA-256: /; s/^SHA256 Fingerprint=/certificate SHA-256: /'
sh oauth/saml-application/http/idp-metadata.sh

Check the result​

Output
metadata URL: https://app.lumoauth.dev/orgs/acme-corp/saml/idp/metadata
IdP entity ID: https://app.lumoauth.dev/orgs/acme-corp/saml/idp/metadata
SSO URL: https://app.lumoauth.dev/orgs/acme-corp/saml/idp/sso (HTTP-Redirect and HTTP-POST)
SLO URL: https://app.lumoauth.dev/orgs/acme-corp/saml/idp/slo
certificate expires: Nov 27 06:04:24 2029 GMT
certificate SHA-256: EA:03:81:13:A5:1D:F1:F0:06:22:BF:ED:7D:49:4F:45:9F:97:DD:51:34:8F:CA:69:B7:EC:00:F9:E4:BB:6D:BB
  • The response and the assertion are both signed with RSA-SHA256. The service provider checks them with the certificate of the metadata.
  • The assertion has the NameID maya.chen@example.com in the format emailAddress, the audience https://wiki.acme.example/saml/metadata, and the recipient that is the ACS URL.
  • Its attributes are the email address and the name, each under two names: urn:oid:0.9.2342.19200300.100.1.3 and http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress for the email address, urn:oid:2.5.4.42 and http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name for the name.
  • In the portal, Security, Audit logs shows the event saml_response_issued. An unsigned sign-in request also writes the warning saml_unsigned_authnreq_accepted.

Limits​

  • The attributes are fixed: email address and name. Roles, groups and custom attributes are not sent, and the portal has no editor for them. Choose the identifier with NameID source: email address, user ID or username.
  • The attribute urn:oid:2.5.4.42 holds the full display name, although that name usually means the given name. Map it in the service provider with care.
  • The sign-in must start at the service provider. LumoAuth has no sign-in that starts on its side.
  • The ACS URL and the SLO URL must be https URLs on a public host. http and localhost are refused.
  • The signing certificate belongs to the organization and is the same for every SAML application. LumoAuth replaces it by itself when fewer than 30 days are left, so give the service provider the metadata URL, and it reads the new certificate. You cannot rotate it from the portal.
  • The metadata says WantAuthnRequestsSigned="true", but an unsigned request is accepted until you turn on Require signed AuthnRequests for the application.