0Pricing
Cloud & IT Cert Prep · Lesson

Federated Identity: SAML, OAuth, and OpenID Connect

Learn how SSO, SAML assertions, OAuth 2.0 flows, and OpenID Connect tokens enable users to authenticate once across many applications securely.

Federated Identity: SAML, OAuth, and OpenID Connect is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Problem of Identity Across Domains

In modern enterprises, employees need to access dozens of applications — cloud apps, SaaS tools, partner portals, and internal systems — each potentially maintained by different organizations. Creating and managing separate accounts for each is insecure (credential proliferation) and inefficient. Federated identity solves this by allowing an Identity Provider (IdP) — a trusted, authoritative source of identity — to authenticate users and share that authenticated identity with Service Providers (SPs) across organizational boundaries. Users authenticate once and gain access to multiple systems without re-entering credentials.

Single Sign-On (SSO) Fundamentals

Single Sign-On (SSO) allows users to authenticate once and access multiple applications within a session without re-authenticating. The user logs in to the Identity Provider (corporate Active Directory, Okta, Azure AD), receives a session token or assertion, and presents this token to each Service Provider they visit. SSO improves security by reducing the number of passwords users must manage (reducing reuse), enabling centralized authentication policy enforcement, and allowing immediate access revocation across all integrated applications when an account is disabled at the IdP level.

SAML 2.0: XML-Based Federation

SAML (Security Assertion Markup Language) 2.0 is the XML-based open standard for exchanging authentication and authorization data between Identity Providers and Service Providers. The SAML flow: (1) user accesses a Service Provider (e.g., Salesforce), (2) SP redirects to the Identity Provider (e.g., Okta), (3) user authenticates at the IdP, (4) IdP issues a signed XML SAML Assertion containing the user's identity and attributes, (5) the assertion is returned to the SP, (6) SP validates the assertion's signature using the IdP's public key and grants access. SAML is widely used for enterprise SSO in web applications.

<!-- Simplified SAML Assertion structure -->
<saml:Assertion xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'
  IssueInstant='2026-06-21T10:00:00Z'
  ID='_abc123'>
  <saml:Issuer>https://idp.company.com</saml:Issuer>
  <saml:Subject>
    <saml:NameID>alice@company.com</saml:NameID>
  </saml:Subject>
  <saml:Conditions NotBefore='2026-06-21T10:00:00Z'
                   NotOnOrAfter='2026-06-21T10:05:00Z'/>
  <saml:AttributeStatement>
    <saml:Attribute Name='groups'>
      <saml:AttributeValue>Sales</saml:AttributeValue>
    </saml:Attribute>
  </saml:AttributeStatement>
  <!-- Signature verifies IdP signed this assertion -->
</saml:Assertion>

SAML Roles: IdP, SP, and Principal

Three parties participate in a SAML federation. The Principal is the user (or system) seeking access — they initiate the authentication process. The Identity Provider (IdP) is the authoritative source of identity that authenticates the principal and issues assertions — examples include Microsoft Azure AD, Okta, Ping Identity, and ADFS. The Service Provider (SP) consumes the assertion and grants access based on it — examples include Salesforce, Google Workspace, AWS, and any SAML-enabled application. The SP and IdP establish trust in advance by exchanging metadata containing each other's endpoint URLs and signing certificates.

OAuth 2.0: Authorization Framework

OAuth 2.0 is an authorization framework (not an authentication protocol) that allows a third-party application to access resources on behalf of a user without exposing the user's credentials. The classic use case: 'Allow this photo editing app to access your Google Photos.' OAuth 2.0 introduces four roles: the Resource Owner (user), the Client (third-party app), the Authorization Server (issues tokens), and the Resource Server (hosts the protected resource). The user authorizes the client, which receives an access token it presents to the resource server — never needing the user's actual password.

OAuth 2.0 Authorization Code Flow

The Authorization Code Flow is the most secure OAuth 2.0 flow for web applications. The flow: (1) Client redirects user to the Authorization Server with requested scopes; (2) User authenticates and grants consent at the Authorization Server; (3) Authorization Server redirects back with a short-lived authorization code; (4) Client exchanges the code for an access token (and optionally a refresh token) via a server-to-server call with client credentials; (5) Client uses access token to call the Resource Server. The code exchange happens server-side, preventing the access token from being exposed in browser history or logs.

# OAuth 2.0 Authorization Code Flow (step 3-4)
# Step 3: User is redirected back to client with auth code
# GET https://app.example.com/callback?code=SplxlOBeZQQYbYS6WxSbIA&state=xyz

# Step 4: Client exchanges code for access token (server-to-server)
curl -X POST https://auth.example.com/oauth2/token \
  -d 'grant_type=authorization_code' \
  -d 'code=SplxlOBeZQQYbYS6WxSbIA' \
  -d 'redirect_uri=https://app.example.com/callback' \
  -d 'client_id=client_abc' \
  -d 'client_secret=secret_xyz'
# Response: {'access_token': 'MTQ0Nj...', 'token_type': 'Bearer', 'expires_in': 3600}

OpenID Connect: Adding Authentication to OAuth

OpenID Connect (OIDC) is an authentication layer built on top of OAuth 2.0. OAuth only provides authorization (access tokens proving what the client can do); OIDC adds authentication (an ID token proving who the user is). OIDC adds an openid scope to the OAuth flow and returns a signed JWT (JSON Web Token) ID Token alongside the access token. The ID token contains claims (name, email, sub [subject identifier]) that identify the user. OIDC is now the dominant protocol for consumer-facing SSO — 'Sign in with Google/Apple/Microsoft' buttons all use OIDC.

# OIDC ID Token is a JWT with three base64url-encoded parts:
# header.payload.signature

# Decoded payload example:
# {
#   'iss': 'https://accounts.google.com',
#   'sub': '110169484474386276334',
#   'aud': 'client_id_abc123',
#   'exp': 1750000000,
#   'iat': 1749996400,
#   'email': 'alice@gmail.com',
#   'name': 'Alice Smith',
#   'email_verified': true
# }

# The signature is verified with the IdP's public key (from JWKS endpoint)

JWT: Tokens in Modern Authentication

JSON Web Tokens (JWT) are a compact, URL-safe format for representing claims between parties. A JWT has three base64url-encoded parts separated by dots: Header (algorithm and token type), Payload (claims: iss, sub, aud, exp, iat, and custom claims), and Signature (cryptographic signature verifying the token's integrity). JWTs are self-contained — the Resource Server can verify them without calling back to the Authorization Server, improving performance and enabling stateless architectures. The critical security requirement: always verify the JWT signature and check the exp (expiry) and aud (audience) claims.

# Decode a JWT (header and payload are just base64 encoded)
import base64, json

jwt = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFsaWNlIiwiZXhwIjoxNzUwMDAwMDAwfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
parts = jwt.split('.')
print('Header:', json.loads(base64.b64decode(parts[0] + '==')))
print('Payload:', json.loads(base64.b64decode(parts[1] + '==')))
# Signature (parts[2]) must be verified with IdP public key!

SAML vs OAuth vs OIDC: When to Use Which

Understanding when each standard applies is critical for the Security+ exam. SAML 2.0: enterprise SSO for web applications, browser-based flows, XML assertions. Legacy but widely deployed in enterprise. OAuth 2.0: API authorization — granting third-party apps limited access to resources. Does not authenticate users directly. OIDC: consumer and modern enterprise authentication (SSO), built on OAuth 2.0. Returns JWT ID tokens identifying the user. In practice: enterprise environments often use SAML for application SSO and OIDC for API/mobile authentication. Modern cloud-native environments prefer OIDC over SAML for its JSON/JWT format and better mobile support.

Federation Attack Vectors

Federated identity systems introduce specific attack vectors. Assertion replay attacks: an attacker intercepts a SAML assertion and replays it to gain access. Mitigated by short assertion lifetimes and one-time-use assertion IDs. XML signature wrapping (XSW): in SAML, attackers can sometimes manipulate signed XML to alter claims while keeping the signature valid on the original content. JWT algorithm confusion: if a server accepts both RS256 (asymmetric) and HS256 (symmetric) algorithms, an attacker can forge JWTs by using the server's public key as the HMAC secret for HS256. Always validate algorithm header matches expected algorithm. Open redirectors: OAuth redirect URIs must be exactly matched to prevent token theft via redirection to attacker-controlled sites.

Directory Federation and SCIM

Enterprise identity federation often requires synchronizing user identity data between systems. SCIM (System for Cross-domain Identity Management) is a REST API standard for automating user provisioning and deprovisioning between an Identity Provider and connected Service Providers. When a new employee is added to Azure AD (IdP), SCIM automatically creates their account in Salesforce, Slack, GitHub, and other SCIM-compatible apps. When the employee is terminated, SCIM deactivates all accounts simultaneously — closing the window where orphaned accounts could be exploited. SCIM complements SSO protocols (SAML/OIDC) by handling the lifecycle management that SSO protocols don't address.

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: SAML 2.0 uses XML assertions for enterprise browser-based SSO; OAuth 2.0 is an authorization framework for API access delegation; OpenID Connect adds authentication (JWT ID tokens) on top of OAuth; and SCIM automates identity lifecycle management across federated systems. This completes the Authentication and Authorization course — next we explore Network Security Fundamentals.

Frequently asked questions

Is the “Federated Identity: SAML, OAuth, and OpenID Connect” lesson free?

Yes — the full text of “Federated Identity: SAML, OAuth, and OpenID Connect” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Federated Identity: SAML, OAuth, and OpenID Connect”?

Learn how SSO, SAML assertions, OAuth 2.0 flows, and OpenID Connect tokens enable users to authenticate once across many applications securely. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Federated Identity: SAML, OAuth, and OpenID Connect” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Password Policies and Multi-Factor Authentication
  2. Biometrics and Token-Based Authentication
  3. Authorization Models: RBAC, MAC, and DAC
  4. Federated Identity: SAML, OAuth, and OpenID Connect
← Back to Cloud & IT Cert Prep