Skip to content

Sign in through a SAML identity provider

A SAML provider lets the people of a realm sign in with an identity provider their organization already runs, such as Microsoft Entra ID, Okta, or ADFS. Authwise is the service provider: it sends the person to the identity provider, receives the signed assertion, and creates or matches the account. This page shows the exchange with Microsoft Entra ID as the example; the steps are the same for any SAML 2.0 identity provider.

  • Identity server 1.68 or later, awctl 0.22 or later, and Terraform provider 0.23 or later. Earlier identity servers send a request that Microsoft Entra ID refuses; see Test the connection.
  • A tenant administrator seat, or a service account holding tenant.admin.
  • A realm and an issuer that routes to it. See Realms and Domains and issuers.
  • Rights on the identity provider side to create an enterprise application and assign people to it.

A SAML connection is a two-way exchange of metadata:

  1. You create the provider in Authwise, which gives you Authwise’s service provider details: its entity ID and its assertion consumer service URL.
  2. You create the application on the identity provider’s side with those details, and download its metadata.
  3. You import that metadata into the provider in Authwise.

When a person signs in, Authwise sends an authentication request to the identity provider’s single sign-on URL. The identity provider signs the person in and posts a signed assertion back to Authwise’s assertion consumer service. Authwise checks the signature against the imported certificate, maps the assertion’s attributes to the account’s fields, and signs the person in.

A SAML sign-in starts in one of two places.

SP-initiated. The person starts at an application that signs in with Authwise. Authwise sends an authentication request to the identity provider, and the identity provider’s response answers that request. This is the way every provider works, with nothing to turn on. It’s also the way to make the identity provider’s own portal work: give the identity provider the application’s sign-in URL, and its portal sends the person to the application, which starts the sign-in. In Microsoft Entra ID, that’s the Sign on URL in the application’s SAML configuration.

IdP-initiated. The person starts at the identity provider’s portal, and the identity provider posts an assertion that answers no request. Authwise accepts such an assertion only when Accept IdP-initiated logins is on, and only into a sign-in that is already in progress in the same browser: the person started at an application, Authwise sent them to the identity provider, and the assertion arrives at the provider’s assertion consumer service without the request’s ID. Authwise doesn’t start a sign-in from an assertion alone, because the assertion names no application to return the person to. A person who starts at the identity provider’s portal with no sign-in in progress sees an error.

Leave Accept IdP-initiated logins off unless a partner’s portal is the intended entry point. Matching a response to the request Authwise sent is what refuses a replayed or unsolicited response; with the setting on, only the signature check and the once-only check on the assertion’s ID stand in the way.

  1. Open the realm, go to Providers, and click New provider.

  2. Click SAML 2.0.

  3. In Display name, enter the label people see on the sign-in page, such as Sign in with Entra ID.

  4. Click Create provider.

    The console opens the provider’s page.

  5. Under Our metadata, click Generate SP metadata and note Our entity ID and Assertion consumer service.

With awctl, in the realm’s context:

Terminal window
awctl identity providers create \
--display-name "Sign in with Entra ID" \
--provider-type saml \
--config '{"@type": "type.googleapis.com/authwise.types.core.v1alpha1.ProviderSaml", "wantAssertionsSigned": true}'
awctl identity providers export-saml-metadata PROVIDER_ID

Replace PROVIDER_ID with the provider’s ID (p-…). The export prints the entity ID, the assertion consumer service URL, and the metadata XML. When the tenant has several issuers, add --issuer tenants/TENANT_ID/issuers/ISSUER_ID to name the one the metadata is for.

Authwise’s details are built from the issuer’s hostname:

DetailValue
Entity IDhttps://HOSTNAME/saml/sp/PROVIDER_ID
Assertion consumer service URLhttps://HOSTNAME/saml/sp/PROVIDER_ID/callback, binding HTTP-POST
Metadatahttps://HOSTNAME/saml/sp/PROVIDER_ID/metadata, readable without signing in

Each hostname the issuer serves has its own entity ID. If the issuer also serves a hostname of your own, register that hostname’s entity ID and assertion consumer service URL on the identity provider as well. See Use your own domain.

Create the application in Microsoft Entra ID

Section titled “Create the application in Microsoft Entra ID”
  1. In the Microsoft Entra admin center, go to Enterprise applications and click New application, then Create your own application.

  2. Enter a name, select Integrate any other application you don’t find in the gallery (Non-gallery), and click Create.

  3. Go to Single sign-on and select SAML.

  4. In Basic SAML Configuration, click Edit and enter:

    • Identifier (Entity ID): Authwise’s entity ID.
    • Reply URL (Assertion Consumer Service URL): Authwise’s assertion consumer service URL.
    • Sign on URL: the URL of the application’s sign-in page, such as https://app.example.com/login. With it set, the application’s tile in My Apps sends the person to the application, which starts an SP-initiated sign-in. Without it, the tile posts an IdP-initiated assertion, which Authwise refuses unless a sign-in is already in progress.

    Leave Relay State and Logout Url empty, and click Save.

  5. In Attributes & Claims, keep the default claims. Authwise reads the email address, given name, surname, and display name from Entra’s default claim names without any mapping. For Unique User Identifier (Name ID), choose the email address or the user principal name, with the format Email address.

  6. In SAML Certificates, next to Federation Metadata XML, click Download.

  7. In Users and groups, assign the people or groups who may sign in.

  1. On the provider’s page in the Authwise console, under Their SAML metadata, click Upload file and choose the downloaded XML, or paste its contents.

  2. Click Check what this changes and review the entity ID, single sign-on URL, and signing certificate it found.

  3. Click Apply import.

    The import fills Entity ID, Single sign-on URL, and Single sign-on binding, and stores the signing certificate as a certificate of the tenant.

  4. Check that Require signed assertions is on, and click Save.

    The import turns it on. A provider with neither Require signed assertions nor Require a signed response turned on requires signed assertions. Identity server 1.56 to 1.67.0 refused every sign-in through such a provider instead; turn one of the two on there.

With awctl:

Terminal window
awctl identity providers import-saml-metadata PROVIDER_ID --file federation-metadata.xml

Add --dry-run to see what the import would change without applying it.

With Terraform, import the certificate and set the identity provider’s details yourself:

resource "authwise_certificate" "entra_signing" {
display_name = "Entra ID signing"
use = "CERTIFICATE_USE_SIGNING"
import_certificate_pem = file("${path.module}/entra-signing.crt")
}
data "authwise_provider_saml" "entra" {
idp_entity_id = "https://sts.windows.net/TENANT_GUID/"
idp_sso_url = "https://login.microsoftonline.com/TENANT_GUID/saml2"
idp_sso_binding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
idp_signing_certificate_id = authwise_certificate.entra_signing.certificate_id
want_assertions_signed = true
name_id_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
}
resource "authwise_provider" "entra" {
realm_id = authwise_realm.employees.realm_id
display_name = "Sign in with Entra ID"
provider_type = "saml"
config = data.authwise_provider_saml.entra.any
}

Replace TENANT_GUID with the Entra tenant’s ID, and take the certificate from the downloaded metadata’s X509Certificate element, wrapped in PEM BEGIN CERTIFICATE and END CERTIFICATE lines. idp_sso_binding is the SAML binding URN. Identity server 1.68 and provider 0.23 also accept the short form HTTP-Redirect and store the URN; earlier versions accept the short form and then refuse every sign-in.

The exchange takes two applies, because each side needs something the other side creates:

  1. Apply the provider without idp_signing_certificate_id. Authwise’s entity ID and assertion consumer service URL contain the provider’s ID, so they exist only after this apply. A provider without the certificate refuses sign-ins until you set it.
  2. Create the application in Entra ID with those two values, download its metadata, and take the certificate from it.
  3. Add the authwise_certificate and idp_signing_certificate_id, and apply again.

Open the realm’s Configuration and, in Provisioning, turn on Just-in-time federation. Without it, a person the realm doesn’t know yet is refused after the identity provider signs them in.

  1. Open the issuer’s sign-in page, such as https://HOSTNAME/authorize through one of the issuer’s clients, or the sign-in of an application that uses it.

  2. If the realm has other sign-in methods, click the provider’s button. If the SAML provider is the realm’s only method, the page sends you to the identity provider at once.

  3. Sign in at the identity provider.

    You land back in the application, signed in. The realm’s Users page lists the new account.

If the identity provider refuses the request, the message on its page says why: most often the entity ID or reply URL doesn’t match what you registered, or the person isn’t assigned to the application. If Authwise refuses the response, it shows an error page with the reason, such as an assertion for a different audience or a signature it couldn’t verify.

Microsoft Entra ID reports these codes for a request from an identity server before 1.69.1. Upgrade; no setting on either side avoids them.

Entra ID codeCause
AADSTS7500510The request’s IssueInstant carried nanoseconds, which Entra ID doesn’t parse. Identity server 1.68 sends whole seconds.
AADSTS75011The request asked for a password sign-in (PasswordProtectedTransport) and the person signed in to Entra ID another way, such as passwordless or an existing session with multifactor authentication. Identity server 1.68 requests no authentication context.
AADSTS900236The request named the person in a Subject element, which Entra ID doesn’t accept. Identity server 1.69.1 sends no Subject; it passes the person’s identifier as a login_hint query parameter instead. See How the person’s identifier reaches the identity provider.

How the person’s identifier reaches the identity provider

Section titled “How the person’s identifier reaches the identity provider”

When a sign-in is routed by email domain or the application passes a login_hint, Authwise already knows the person’s identifier when it sends them to the identity provider. It passes the identifier along so the person doesn’t type it twice.

By default, Authwise adds the identifier to the identity provider’s single sign-on URL as a login_hint query parameter. Microsoft Entra ID, Google Workspace, and Okta read this parameter and pre-fill the account. The request itself carries no Subject element, because Entra ID refuses one and Google Workspace ignores it.

For an identity provider that reads the Subject element instead, or one that must receive nothing, set identifier_hint on the provider. The provider’s page has no field for it yet; set it in Terraform on data.authwise_provider_saml (provider 0.24.0 or later), or in the JSON you pass to awctl identity providers update --config (awctl 0.30.0 or later). Identity server 1.70.0 or later.

identifier_hintWhat Authwise sends
LOGIN_HINT_QUERYThe identifier as a login_hint query parameter on the single sign-on URL. Default.
SUBJECTThe identifier as the request’s Subject NameID, in the requested NameID format. Entra ID refuses this with AADSTS900236.
NONENothing. The person types their identifier at the identity provider.

To ask the identity provider for a particular authentication method, set requested_authn_context with a comparison of exact, minimum, better, or maximum, and at least one class_refs entry, such as urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport. Leave it unset unless the identity provider documents that it needs one: Entra ID requires exact and fails a sign-in that doesn’t match, as the AADSTS75011 row shows.

data "authwise_provider_saml" "entra" {
# ...
identifier_hint = "LOGIN_HINT_QUERY"
}

The provider’s page has these settings. The defaults suit Microsoft Entra ID and most other identity providers.

SettingWhat it doesDefault
Entity ID, Single sign-on URL, Single sign-on bindingThe identity provider’s identity and where Authwise sends the authentication request. The binding is a SAML binding URN; Authwise sends the request by HTTP-Redirect only, so the value is urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect.Filled by the import
Their signing certificateThe certificate Authwise checks assertions with.Filled by the import
Require signed assertionsRefuse an assertion that isn’t signed. Turn it on.Off
Require a signed responseRefuse a response that isn’t signed. Some identity providers sign the response instead of the assertion.Off
Sign AuthnRequestsSign the request Authwise sends. Needs Our signing certificate, minted on the tenant’s Certificates page. The import turns it on when the identity provider’s metadata asks for signed requests.Off
Our signing certificateThe certificate Authwise signs requests with and decrypts assertions with.None
Requested NameID formatThe identifier format Authwise asks for: Email address, Persistent, Transient, Unspecified, or Not requested.Unspecified
Allow createTell the identity provider it may create an identifier for a person it hasn’t seen.Off
Accept IdP-initiated loginsAccept an assertion the identity provider sends without a request from Authwise, into a sign-in already in progress. See SP-initiated and IdP-initiated sign-in.Off
Accept SHA-1 signaturesFor an identity provider that can’t sign with SHA-256.Off
Clock skew tolerance (seconds)How far the assertion’s timestamps may differ from Authwise’s clock.120

The Identity section says which part of the assertion identifies the person and which attributes fill the account.

Identifier source (identifier_source) names the part of the assertion that becomes the person’s identifier in Authwise. It takes one of two forms:

ValueUse it when
assertion.name_idThe identity provider’s NameID is stable and meaningful, such as an email address or a persistent identifier. Default.
assertion.attributes.NAMEThe NameID is transient or opaque and an attribute carries the identifier instead, such as assertion.attributes.http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress.

Choose it before the first sign-in. Authwise links each account to the identifier it saw first, so changing the source later makes existing people look new.

The attribute mapping defaults to the claim names Microsoft Entra ID sends:

Account fieldAssertion attribute
emailhttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
given_namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
family_namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
display_namehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
preferred_usernamehttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn

To map an attribute yourself, add a row under Attribute mapping with the account field and the source assertion.attributes.NAME, where NAME is the attribute’s name in the assertion. Add [] after the name to take every value of a multi-valued attribute. A mapping you set replaces the defaults, so include every field you need. A SAML assertion has no way to say an address is verified, so by default the address is kept as stated and the person proves it the first time they use it. To count the addresses of the directory’s own domains as verified, see Trust what an identity provider says.

Trust the identity provider’s statements

Section titled “Trust the identity provider’s statements”

Under Advanced, the Trust in the upstream row decides whether the identity provider’s statements count in Authwise. Trust the upstream’s authentication methods with Upstream level mapping lets a second factor the identity provider enforced count as one in Authwise, so the person isn’t asked twice. Trusted email domains with Count the upstream’s email as verified lets the addresses of the directory’s own domains count as verified. All are off by default and need identity server 1.98.0 or later on a SAML provider. See Trust what an identity provider says for what each costs and the values for Microsoft Entra ID.