A cloud expenses service lets a client firm's staff sign in with their work accounts. The firm's own sign-in service checks each person's password and second factor, then sends the service a signed statement about them.
Federation: SAML, OAuth 2.0 and OpenID Connect
When a website offers to let someone sign in with an existing work or email account, it is trusting another organisation to say who that person is. That arrangement is federation. No background is assumed. A security professional has to know what passes between the parties and what the receiving service must check. The three common standards also differ: some sign people in, and one grants permission.
By the end of this unit you will be able to:
- Explain federated identity management and name the identity provider, the relying party and the assertion
- Put the steps of a federated sign-in in order, including what the relying party checks
- Tell apart SAML, OAuth 2.0 and OpenID Connect by what each is for
- Name the four OAuth 2.0 roles and tell apart an access token, a refresh token and an ID token
- Choose the right standard for a described sign-in or delegation
A training site that never saw the password
An illustrative example
A charity buys courses for its volunteers from an online training company. On the training site, a volunteer coordinator clicks a button labelled Sign in with charity account.
She lands on the charity's own sign-in page, types her usual password and approves a prompt on her phone. A moment later she is back on the training site, signed in, with her name and team already filled in. The training company holds no password for her.
The training site never received her password. How does it know who she is, and why should it believe it?
Trusting another organisation's sign-in
Federated identity management (FIM) is an arrangement in which separate organisations agree to accept one another's authentication. A user signs in once with the organisation that knows them, and services run by others accept that result.
- Identity provider (IdP)
- The organisation, or its service, that authenticates the user and vouches for them. In the opening case, the charity.
- Relying party (RP)
- The service that accepts the identity provider's word instead of authenticating the user itself. In it is called the service provider (SP). In the opening case, the training site.
- Assertion
- A signed statement from the identity provider to the about the user: who they are, when and how they authenticated, and any attributes such as team or role.
- Trust agreement
- What the parties settle in advance: which identity provider, which keys sign the assertions, which attributes are sent, and what each side must do when an account is closed.
and federation overlap and are not the same. Single sign-on is the user's experience of signing in once. Federation is the trust between separate organisations, or separate security domains, that makes single sign-on possible across them.
The relying party gains a user it never has to register or protect a password for. It also hands authentication to someone else, so its security now depends on the identity provider's sign-in and on its own checking of every assertion.
A federated sign-in, step by step, and what the relying party checks
The user's browser carries the messages between the two parties, which need not talk to each other directly during sign-in.
- The user asks the relying party for a protected page.
- The relying party has no session for the user, so it sends the browser to the identity provider with a request for authentication.
- The identity provider authenticates the user with its own methods, such as a password and a second factor.
- It creates an assertion about the user, signs it with its private key, and sends the browser back with it.
- The relying party checks the assertion. If every check passes, it starts its own session for the user.
The browser carries a signed assertion between parties
Read this figure as text
In federation, separate organisations accept one another's authentication. The user's browser carries every message between them, so the two need not talk to each other during sign-in.
- The user asks the relying party, the application they want, for a protected page. In SAML the relying party is called the service provider. It has no session for the user and holds no password for them, so it sends the browser to the identity provider with an authentication request.
- The browser delivers the request. The identity provider authenticates the user with its own methods, such as a password and a second factor.
- The identity provider creates an assertion, a statement of who the user is, when and how they authenticated, and attributes such as team or role. It signs it with its private key and sends the browser back with it. The assertion is a SAML assertion or an OpenID Connect ID token.
- The relying party makes five checks: the signature, made by the agreed key over unchanged content; the issuer, named in the trust agreement; the audience, this relying party; the time, within its validity period; and freshness, an answer to a request it actually sent and not used before. Failing any one refuses the assertion.
- The trust agreement was settled beforehand: which identity provider, which keys sign the assertions, which attributes are sent and what each side does when an account closes.
- Only after every check passes does the relying party start its own local session, which is separate from the identity provider's session.
- Signature: made by the identity provider's key, as agreed, and the content is unchanged.
- Issuer: the identity provider named in the trust agreement.
- Audience: the assertion was made for this relying party, not for another service.
- Time: it is within its validity period and has not expired.
- Freshness: it answers a request this relying party actually sent and has not been used before. A copied assertion sent again is a replay.
An assertion that fails any one check is refused, and no session starts.
SAML: signed XML statements carried through the browser
Security Assertion Markup Language (SAML) 2.0 is a standard from the OASIS consortium, published in March 2005, for exchanging assertions between an identity provider and a service provider. It is designed above all for sign-in through a web browser. Its assertions are written in XML, a text format that marks each piece of data with named tags, and are signed with XML Signature.
SAML names three roles: the principal, the user being authenticated; the identity provider; and the service provider.
- Authentication statement
- When and how the principal authenticated, for example with a password and a phone at 09:02.
- Attribute statement
- Facts about the principal, such as department, email address or role.
- Authorisation decision statement
- Whether the principal may perform a stated action on a stated resource.
In a service-provider-initiated sign-in, the user starts at the application, which sends them to the identity provider, as in the steps above. In an identity-provider-initiated sign-in, the user starts at the identity provider's portal and clicks a link to the application, which receives an assertion it never asked for. That leaves the service provider no request to match, so it relies more heavily on the time and one-use checks.
WS-Federation is another OASIS standard, from 2009, for sharing identity between separate security domains, including through a browser.
OAuth 2.0 grants permission; it does not sign anyone in
A printing app and a photo library
A photo-printing app asks to read a customer's online photo library. The customer is sent to the library's own page, signs in there, and sees: allow this app to view photos? She agrees.
The app receives a pass that lets it read photos and nothing else. It never sees her password, and she can withdraw the pass later.
OAuth 2.0 is a framework for delegated authorisation: a user lets one application act on their resources at another service, within limits, without handing over a password. Its standard defines four roles.
- Resource owner
- The person who can grant access: the customer.
- Client
- The application that wants access: the printing app.
- Authorisation server
- The service that asks the owner for consent and issues tokens.
- Resource server
- The service holding the data, which accepts the tokens: the photo library.
An access token is the pass the client presents to the resource server. It is short-lived and limited by scope, the list of permissions granted, such as read photos only. A refresh token lets the client obtain a new access token without asking the user again. The user's agreement is called consent.
The usual way to obtain tokens is the authorisation code grant, with the browser redirects shown above. The client credentials grant serves a program acting on its own behalf, with no user. Two older grants are now discouraged: the implicit grant leaks tokens, and the password grant hands the user's password to the client.
OpenID Connect adds who the user is
An access token says what a client may do. It is meant for a resource server, and it tells the client nothing reliable about who the user is. Using one as proof of sign-in is a classic mistake. OpenID Connect (OIDC) fixes this by adding an identity layer on top of . Its identity provider is the OpenID provider, and the client is the relying party.
With the access token, returns an ID token: an assertion about the sign-in, written as a JSON Web Token (JWT). A JWT is a compact set of named values, called claims, that is so the relying party can check it. Its claims include iss, the issuer, and sub, the user's identifier at that issuer. aud names the client it is for, and exp and iat say when it expires and was issued. nonce is a random value from the relying party's request that stops replay.
The relying party checks the issuer, that its own identifier is in the audience, the signature, the expiry, and that the matches the one it sent.
| Point | SAML 2.0 | OAuth 2.0 | OpenID Connect |
|---|---|---|---|
| Answers | Who is this user, and what are their attributes? | What may this application do for the user? | Who is this user, for an application built on OAuth? |
| Main token | XML assertion | Access token, with refresh token | ID token (a JWT), with access token |
| Typical use | Signing in through a web browser | Apps reaching data through programming interfaces | Signing in to web and mobile apps |
| Kind of function | Authentication and attributes | Authorisation only | Authentication |
A question, worked through
A gym chain is building a mobile app. Members will sign in with their existing accounts at a large email provider, which supports OAuth 2.0 and OpenID Connect only. The app must know which member has signed in. A developer proposes requesting an OAuth 2.0 access token for the provider's contacts service and treating its arrival as proof of who the member is.
What should the security manager recommend INSTEAD?
Decide on your answer, then open the reasoning
- The question asks how the app should learn who signed in. The proposal uses an authorisation token as if it were proof of identity.
- Rule out b: a broader scope gives the app more permission. An access token still says what the app may do, not who the user is, and more scope adds risk.
- Rule out d: a separate password abandons federation and gives the gym a password store to protect.
- Between a and c: both are built for sign-in. But the provider supports only OAuth 2.0 and OpenID Connect, so SAML is not available here.
- OpenID Connect returns an ID token addressed to the app, with the issuer, the user's identifier, an expiry and a nonce. The app validates it. Option a is the best answer.
Answer: A. Use OpenID Connect and validate the ID token it returns
Choosing between good answers
- The need is for an application to act on a user's data elsewhere without the password
- choose OAuth 2.0. It is delegated authorisation.
- The need is to know who the user is
- choose SAML for staff web sign-in or OpenID Connect for apps built on OAuth. An OAuth access token alone is not proof of identity.
- A relying party accepts an assertion meant for a different service
- the audience check failed. Choose the answer that validates audience, issuer, signature, time and one-time use.
- A question names XML assertions, a principal and a service provider
- it is describing SAML 2.0. A JWT and claims such as iss, sub and aud mean OpenID Connect.
Try it
Follow a sign-in from the application to the identity provider and back, and see which check refuses a token made for another service.
Loading the preview.
Check your understanding
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
What to remember
- Federation is trust between organisations: the identity provider authenticates the user and the relying party accepts its signed assertion.
- A relying party must check every assertion's signature, issuer, audience, validity time and freshness, or it can be replayed or misdirected.
- SAML 2.0 carries signed XML assertions through the browser, with three statement types: authentication, attribute and authorisation decision.
- OAuth 2.0 is delegated authorisation, with four roles and scoped access tokens. It does not by itself sign a user in.
- OpenID Connect adds an ID token, a signed JWT, on top of OAuth 2.0, which makes it a sign-in standard.
Say it from memory
What is federated identity management, and what do SAML, OAuth 2.0 and OpenID Connect each do in it?
Separate organisations agree to accept one another's authentication. An identity provider authenticates the user and sends a signed assertion to a relying party. That party checks signature, issuer, audience, time and freshness. SAML 2.0 carries XML assertions for web sign-in. OAuth 2.0 grants scoped access tokens for delegated authorisation. OpenID Connect adds a signed ID token on OAuth for sign-in.
In what order does a federated sign-in run?
The user asks the relying party for a protected page. Having no session, the relying party sends the browser to the identity provider. The identity provider authenticates the user, creates an assertion, signs it and sends the browser back with it. The relying party checks the assertion and, if every check passes, starts its own session.
What three kinds of statement can a SAML assertion carry, and why is an identity-provider-initiated sign-in riskier?
Authentication statements say when and how the principal authenticated. Attribute statements give facts such as department or role. Authorisation decision statements say whether the principal may perform an action on a resource. In an identity-provider-initiated sign-in the service provider has no request to match, so it relies more on the time and one-use checks.
What are the four OAuth 2.0 roles, and how does an access token differ from a refresh token?
Resource owner, client, authorisation server and resource server. An access token is the short-lived pass the client presents to the resource server, limited by scope. A refresh token lets the client obtain a new access token without asking the user again. The implicit and password grants are now discouraged.
Why is an OAuth access token not proof of sign-in, and what does OpenID Connect add?
An access token says what a client may do, is meant for a resource server, and tells the client nothing reliable about who the user is. OpenID Connect adds an identity layer: an ID token, a signed JSON Web Token whose claims include issuer, subject, audience, expiry, issue time and a nonce that stops replay.
Sources
- Security Assertion Markup Language (SAML) V2.0 Technical Overview, OASISSAML identity provider, service provider and principal roles, the authentication, attribute and authorisation decision statements, service-provider-initiated and identity-provider-initiated web sign-in, XML assertions signed with XML Signature, and NotOnOrAfter, audience restriction and InResponseTo against replay and misuse.
- Assertions and Protocols for the OASIS Security Assertion Markup Language (SAML) V2.0, OASISSAML 2.0 core specification approved as an OASIS Standard in March 2005.
- Web Services Federation Language (WS-Federation) Version 1.2, OASISWS-Federation 1.2, an OASIS Standard of 22 May 2009, for sharing identity across security realms, including a browser profile.
- RFC 6749: The OAuth 2.0 Authorization Framework, IETFThe four OAuth roles, access and refresh tokens, scope, and the authorisation code, implicit, password and client credentials grants.
- RFC 9700: Best Current Practice for OAuth 2.0 Security, IETFThat clients should not use the implicit grant, and that the resource owner password credentials grant must not be used.
- OpenID Connect Core 1.0 incorporating errata set 2, OpenID FoundationOpenID Connect as an identity layer on OAuth 2.0, the ID token as a JWT with iss, sub, aud, exp, iat and nonce claims, the OpenID provider and relying party, and the checks a client makes on an ID token.
- RFC 7519: JSON Web Token (JWT), IETFA JWT as a compact set of claims encoded in JSON that can be digitally signed.
- NIST SP 800-63C-4: Federation and Assertions, NISTThe identity provider, relying party, assertion and trust agreement as the parts of a federation.
- CISSP Student Glossary, ISC2SAML 2.0 and OAuth as ISC2 uses the terms.