NameID and attributes
An assertion carries two kinds of information about Avery: the NameID that says which account she is, and attributes that describe her. This lesson follows why the first must stay stable while the second can change, how a service asks for the identifier it needs, and why it should receive and trust only the attributes its task needs.
The account behind the name
Six months after joining, Avery marries and changes her surname, and Cedar Inc. updates her display name and her email address, from [email protected] to [email protected]. The next morning she signs in to the training service and finds all her completed courses where she left them. The training service did not match her by name or email. It matched her by the identifier in the assertion's NameID, which did not change.
That identifier is the anchor of the relationship. When the training service first saw Avery, it linked the pair (Cedar Inc.'s entity ID, cedar-training-742) to a local account, and every later sign-in follows that link. Names, addresses and departments can change around it. What kind of identifier the NameID is, and what promises come with it, is set by its format, a URN written in the NameID's Format attribute.
NameID formats
| Format | URN | What it promises |
|---|---|---|
| Persistent | urn:oasis:names:tc:SAML:2.0:nameid-format:persistent | A stable, opaque identifier made for one identity provider and service provider pair |
| Transient | urn:oasis:names:tc:SAML:2.0:nameid-format:transient | A random value for one session only |
| Email address | urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress | The value is written as an email address |
| Unspecified | urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified | Nothing; its meaning comes from the agreement |
A persistent identifier is pairwise by design, like the pairwise subjectA subject identifier that an OpenID Provider calculates separately for each relying party, or each group of relying parties sharing a sector, so that two unrelated services cannot match up the same person by comparing sub values. identifiers of Public and pairwise subject identifiers. SAMLThe Security Assertion Markup Language, a federation standard widely used for workplace single sign-on, in which the identity provider sends the application a signed assertion about the user. Core, the main SAML specification, requires it to be pseudo-random, with no discernible connection to Avery's username or email, and forbids Cedar Inc. from sharing it with any service providerSAML's name for the application that relies on an identity provider's sign-in, which OpenID Connect calls a relying party. In SCIM, the same term means the application that stores the accounts. other than the one it was made for. So the training service knows Avery as cedar-training-742 and the expense service knows her as cedar-expenses-193, and the two cannot compare notes to track her across services. Real values are random strings such as 4f9c2e71-a0b3-4d58-9e16-c2b8f04a7d31; these lessons use short readable stand-ins. The identifier stays the same as long as the relationship lasts, which is exactly what an account link needs. Two attributes on the NameID qualify it: NameQualifier, the identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider. that issued it, and SPNameQualifier, the service provider it was issued for.
Because the identifier is only unique within its pair, the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts. is part of it. Birch Ltd., another company whose staff use the training service, signs its people in through its own identity provider. If Birch Ltd. happened to send the characters cedar-training-742 for one of its employees, that would be a different person. The training service stores the issuer and the NameID together, and looks them up together.
A transient identifier changes every sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier.. It suits services that need no lasting account, such as a library database that only needs to know a sign-in is valid, and it cannot be an account key. An email address format says only how the value is written. It does not say the address was verified, and it does not say the address will stay the same, as Avery's marriage showed. Linking accounts by email-format NameIDs means an address change looks like a new person, and an address reused by a new employee looks like the old one.
Asking for a format
The training service asks for the format it wants in its AuthnRequest, with the NameIDPolicy element that SAML bindings showed inside a request:
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
AllowCreate="true"/>AllowCreate="true" permits Cedar Inc. to create a new persistent identifier if Avery has none for the training service yet, which happens on her very first sign-in. With AllowCreate="false", Cedar Inc. may only use an identifier that already exists. SPNameQualifier in the policy can ask for an identifier shared by a group of related services instead of the requester alone.
If Cedar Inc. cannot meet the policy, perhaps because it does not support the format, or because AllowCreate is false and no identifier exists yet, it must not quietly send something else. It returns a response with no assertion and a specific status:
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester">
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"/>
</samlp:StatusCode>
</samlp:Status>A status codeThe three-digit number at the start of an HTTP response that says how the request went, such as 200 for success, 302 for a redirect, or 401 when authentication is needed. can hold a second, nested status code that narrows it. The outer code, Requester, says the problem lies with the request; the inner code, InvalidNameIDPolicy, says which part. The training service should show Avery a clear error and record the status, not retry with a looser policy behind her back.
Changing format later needs a plan. If the two organizations switch from email identifiers to persistent ones, every existing account is linked to the old values. The training service must map old to new deliberately, for example by having each person sign in once while both values are sent, rather than let the new identifier create a second account or, worse, attach to whichever existing account shares an email address.
Attributes say something different
The NameID says which subject. Attributes, carried in the assertion's AttributeStatement as Reading an assertion showed, say things about the subject. Here are two from Avery's assertion after her name change:
<saml:Attribute Name="urn:oid:0.9.2342.19200300.100.1.3" FriendlyName="mail"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>[email protected]</saml:AttributeValue>
</saml:Attribute>
<saml:Attribute Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.7" FriendlyName="eduPersonEntitlement"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
<saml:AttributeValue>urn:example:training:course-author</saml:AttributeValue>
<saml:AttributeValue>urn:example:training:learner</saml:AttributeValue>
</saml:Attribute>Name is the attribute's real name, here an object identifier from a published directory schema, so that two organizations mean the same thing by it. The second one, eduPersonEntitlement, comes from a schema written for universities that many federations reuse to say what a person is entitled to. NameFormat says what kind of name it is: uri for these, or basic for a simple agreed string such as department. FriendlyName is a human-readable label and should not be used for matching. An attribute can carry several values, as the entitlementThe umbrella word for anything an account has been granted in a system: a group membership, a role, a permission, or a specific capability. does.
Attributes change, and they mean only what the agreement says. A department from Cedar Inc.'s HR system is a different kind of fact from a job title Avery typed into her own profile. The training service may display Cedar Inc.'s name for her, but decide course permissions from its own roles, or deliberately map an agreed entitlement value to one of its roles. That mapping is the training service's decision. A signed attribute does not order it to grant anything; a value it does not recognize should grant nothing.
Release and trust only what the task needs
The training service needs Avery's identifier, her name for certificates and her department for assigned courses. It does not need her birth date, home address or full list of groups, so Cedar Inc. does not release them. Every attribute released is data the service provider must protect and may lose, and federationAn arrangement that lets systems accept identity information from another trusted system, so an application can rely on a sign-in performed by a separate identity provider. agreements should list the release explicitly.
An assertion is a snapshot from the moment of sign-in. If Avery moves to a new department at lunchtime, the session she started that morning still carries the old one until she signs in again. Services that need current values for sensitive decisions refresh them, or keep sessions short.
Missing values need a planned answer too. If the department is absent, a department-restricted course stays closed, or the service asks for the missing detail through a supported step. An empty or unfamiliar value must never fall through to the most generous default.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Keep the SAML account link separate from profile claimsSign in through a persistent NameID that keeps one account, then change a name mapping and see it affect only new accounts, and a missing name refused instead of guessed.