Route sign-ins by email domain
An issuer normally sends every sign-in to one realm. With routing, the sign-in page asks for the person’s email address first and uses its domain to choose where they authenticate: a partner’s domain goes to the partner’s realm and straight on to its single sign-on, and everyone else goes to your own password or magic-link sign-in. This page shows how to turn an issuer’s routing on and write its rules.
Before you begin
Section titled “Before you begin”- Identity server 1.56 or later,
awctl0.22 or later, and Terraform provider 0.19 or later. - A tenant administrator seat, or a service account holding
tenant.admin. - The realms, each with at least one sign-in method, and the issuer. See Realms and Domains and issuers.
How a sign-in is routed
Section titled “How a sign-in is routed”Routing looks at the shape of the identifier and nothing else:
- The identifier’s domain is the part after its last
@, compared without regard to case. - The issuer’s rules are tried in order, and the first one that matches wins. A rule matches on its domains, on its condition, or on both when it has both.
- An identifier no rule matches goes to the default target, which every routing issuer must have.
Nothing is looked up to route, so the first screen never reveals whether an address has an account. The person sees one field, and after entering it, the credential step of the realm they were routed to, with the address shown and a Not you? link that starts again. The address they entered is the one they sign in as: a password is checked against it, a magic link is sent to it, and a SAML identity provider receives it as a subject hint.
Turn on routing
Section titled “Turn on routing”- Open the issuer and go to Configuration.
- In Login routing, set Mode to Multi realm, routed by identifier.
- In Served realms, select every realm a sign-in at this issuer can end in, including a realm that only a condition routes to. Rule targets and the default are chosen from this list, and Authwise reads this list, not the rules, to decide which issuers serve a realm. An invitation is sent from an issuer that serves the person’s realm, and the invite dialog offers only the applications of those issuers, so a realm that isn’t listed can’t be reached by a rule or named on an invitation.
- In Identifier, leave E-mail address, or choose Username or Either. Domain rules need an email address, so a username-only identifier allows conditions only.
- Optional: in Field label, enter the wording of the first screen’s
field, such as
Work email. - In Default, select the realm, and optionally the provider, for an address no rule matches.
- Click Add rule for each domain you route, and fill it in as described in the next section.
- Click Save.
Authwise checks the whole configuration when you save and refuses a mistake with the field named, so an error fails the save rather than a sign-in.
Write a rule
Section titled “Write a rule”Each rule has a name, what it matches, and where it sends the person.
| Field | What to enter |
|---|---|
| Name | Unique on the issuer. It’s recorded on each sign-in’s audit event as routing_rule. |
| Domains | One or more domains. partner.example matches that domain exactly. *.partner.example matches any subdomain of it, but not partner.example itself. Use lowercase, and the xn-- form of an internationalized domain. |
| Condition | Optional. An expression over identifier, local_part, and domain that returns true or false, in the Common Expression Language. With domains also set, both must hold. |
| Realm | The realm the person signs in to. |
| Provider | Optional. One of that realm’s sign-in methods, to skip the realm’s own choice. Empty lets the realm choose: its username and password method if it has one, otherwise its only method, otherwise a choice of buttons. |
Rules are tried in the order shown; use Move up and Move down to change it. A rule with a condition can share a domain with a rule after it. A rule without a condition takes the whole domain, so a later rule on that domain is refused as unreachable.
A condition is useful where a domain alone isn’t enough. These two rules
send ext-ana@partner.example to your own realm and every other
partner.example address to the partner’s:
| Rule | Domains | Condition | Realm |
|---|---|---|---|
contractors | partner.example | local_part.startsWith("ext-") | Employees |
partner | partner.example | Partner |
Configure routing with awctl or Terraform
Section titled “Configure routing with awctl or Terraform”The routing is the issuer’s multiRealmProviderSelector configuration,
written as a whole. With awctl:
awctl identity issuers update ISSUER_ID --config '{ "multiRealmProviderSelector": { "realmNames": ["tenants/TENANT_ID/realms/REALM_A", "tenants/TENANT_ID/realms/REALM_B"], "identifier": {"label": "Work email"}, "rules": [ { "name": "partner", "domains": ["partner.example", "*.partner.example"], "target": { "realmName": "tenants/TENANT_ID/realms/REALM_B", "providerName": "tenants/TENANT_ID/realms/REALM_B/providers/PROVIDER_ID" } } ], "defaultTarget": {"realmName": "tenants/TENANT_ID/realms/REALM_A"} }}'Replace ISSUER_ID, TENANT_ID, REALM_A, REALM_B, and PROVIDER_ID
with the IDs the console or awctl shows.
With Terraform, build the configuration with the authwise_issuer_config
data source. This example sends a partner’s domain straight to the
partner realm’s SAML provider and everyone else to the employees realm:
data "authwise_issuer_config" "login" { multi_realm_provider_selector = { realm_names = [ authwise_realm.employees.name, authwise_realm.partner.name, ]
identifier = { label = "Work email" }
rules = [ { name = "partner" domains = ["partner.example", "*.partner.example"] target = { realm_name = authwise_realm.partner.name provider_name = authwise_provider.partner_saml.name } }, ]
default_target = { realm_name = authwise_realm.employees.name } }}
resource "authwise_issuer" "login" { domain_id = authwise_domain.main.domain_id config = data.authwise_issuer_config.login.json}What Authwise refuses
Section titled “What Authwise refuses”A save, an awctl update, or a Terraform apply is refused when the
routing has one of these mistakes:
- a served realm that isn’t in the issuer’s tenant;
- a target realm that isn’t a served realm, or a target provider that isn’t in its realm;
- no default;
- a rule with no name, a duplicate name, or neither domains nor a condition;
- a domain that isn’t lowercase, or has
*anywhere but a leading*.; - a condition that doesn’t compile or doesn’t return true or false;
- a domain that an earlier rule without a condition already takes;
- a domain rule when the identifier is a username.
Applications that know the person
Section titled “Applications that know the person”An application that already knows who is signing in can send OpenID
Connect’s login_hint on its authorization request. The hint is routed
exactly as if the person had typed it, so they skip the first screen and
can still click Not you? to enter another address. An issuer that
sends every sign-in to one realm ignores login_hint.
When the default realm offers passkeys, the browser can offer the person’s passkeys on the first screen before they type anything. Choosing one signs them in to the default realm.
Limits
Section titled “Limits”- The first screen accepts 60 attempts a minute from one client address,
then answers
429until the minute passes and records asecurity.rate_limitedevent. - An invitation or password-reset link resolves only on an issuer that sends every sign-in to one realm. In identity server 1.56, a routing issuer can’t deliver them (kit#812). Send invitations from another issuer of the tenant, or open self-signup and just-in-time federation on the realms instead.
What’s next
Section titled “What’s next”- Sign in through a SAML identity provider: the provider a partner’s domain routes to.
- Sign in with a magic link: a passwordless default for everyone else.