Skip to content
advanced Phase 6 · Identity & Access Management

Federation and SSO

Configure identity federation with SAML 2.0, AWS SSO, and OAuth for single sign-on across cloud accounts and enterprise directories.

55m
0 problems
Topic Progress 0%

SAML 2.0 Federation

SAML 2.0 (Security Assertion Markup Language) enables single sign-on between your corporate identity provider (IdP) and AWS. Users authenticate with the IdP and receive temporary AWS credentials without separate AWS logins.

The SAML flow works as follows: the user accesses the AWS Management Console, is redirected to the corporate IdP, authenticates, receives a SAML assertion, and posts it to the AWS SAML endpoint. AWS validates the assertion and grants temporary console access.

Configuration Steps:

  1. Create an IAM role with a trust policy for the IdP (SAML provider ARN as principal)
  2. Register the SAML provider in IAM using the IdP metadata document
  3. Configure the IdP with AWS endpoint URLs and the IAM role ARN

For example, a company using Azure AD as their IdP configures SAML federation so employees log in with their corporate credentials. The SAML assertion includes role attributes that map to IAM roles. Developers get a DeveloperRole while finance users get a FinanceRole.

Attribute Mapping translates IdP attributes to AWS role session names and tags. Map email to RoleSessionName so CloudTrail logs show which corporate user performed each action.

SAML federation supports both console access and programmatic access via the AWS CLI using aws sts assume-role-with-saml.

AWS IAM Identity Center

AWS IAM Identity Center (formerly AWS SSO) is the recommended approach for managing access to multiple AWS accounts and business applications. It provides centralized authentication and authorization.

Permission Sets define the level of access users have in each account. A permission set is a collection of administrator-defined policies that specify what users can do. For example, a ReadOnly permission set attaches the ReadOnlyAccess managed policy, while a FullAdmin permission set attaches AdministratorAccess.

Account Assignments map users or groups to permission sets in specific accounts. A user assigned the DeveloperRole permission set in Account A and ReadOnlyRole in Account B can perform different actions in each account through a single login.

Configuration Flow:

  1. Connect an external identity provider (Azure AD, Okta, PingIdentity) or use the built-in Identity Center directory
  2. Create permission sets with the desired policies
  3. Assign users or groups to permission sets in target accounts
  4. Users access the Identity Center portal and see assigned accounts

For example, a startup with 5 AWS accounts (development, staging, production, logging, security) uses Identity Center. Developers get DeveloperRole in development and staging, ReadOnlyRole in production, and no access to logging or security accounts.

Identity Center also integrates with business applications like Salesforce and Box, providing a single portal for all corporate application access.

OIDC Federation and Web Identity

OpenID Connect (OIDC) federation enables web and mobile applications to obtain temporary AWS credentials using external identity providers like Google, Facebook, Amazon, or corporate OIDC providers.

Web Identity Federation allows users to authenticate with a supported web identity provider and receive temporary AWS credentials. The application redirects to the IdP, receives an OIDC token, and exchanges it for temporary credentials via the AWS AssumeRoleWithWebIdentity API.

For example, a mobile app allows users to sign in with their Google account. The app sends the Google OIDC token to AWS, which validates it and returns temporary credentials scoped to the user's identity.

OIDC for Workload Identity is used for workloads that need to authenticate to AWS without long-term credentials. GitHub Actions, for example, can assume an IAM role by presenting a GitHub-issued OIDC token. This eliminates the need to store AWS access keys as GitHub secrets.

A GitHub Actions workflow assumes a role:

- uses: aws-actions/configure-aws-credentials@v4
  with:
    role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
    aws-region: us-east-1

The trust policy for the role specifies GitHub as the principal and uses conditions to verify the repository and branch:

"Condition": {
  "StringLike": {
    "token.actions.githubusercontent.com:sub": "repo:org/repo:ref:refs/heads/main"
  }
}

This ensures the role can only be assumed from the specified repository and branch.

Cognito Identity Pools

Amazon Cognito provides user pools for authentication and identity pools for authorization. Identity pools grant temporary AWS credentials to users authenticated by any supported provider.

User Pools handle user registration, sign-in, and account recovery. They manage user directories and support MFA, password policies, and custom attributes. User pools are a managed user directory, not an identity provider.

Identity Pools (Federated Identities) exchange tokens from any supported provider (Cognito User Pools, Google, Facebook, Apple, SAML) for temporary AWS credentials. The temporary credentials grant access to AWS services based on IAM policies.

Unauthenticated Access allows identity pools to grant limited AWS credentials to anonymous users. For example, a public mobile app might allow unauthenticated users to read public content but require authentication for writing comments.

Token-Based Access: Identity pools validate tokens from the configured provider and return temporary credentials. The credentials are scoped to the IAM role mapped to the identity type (authenticated or unauthenticated).

For a real-time chat application, users authenticate via Cognito User Pools. The identity pool issues temporary credentials with permissions to read/write to a DynamoDB table for their own messages. Unauthenticated users can view public channels but cannot send messages.

Sync Configuration across devices uses Cognito Sync (now part of AppSync) to persist user preferences and application state. The temporary credentials from the identity pool grant access to the Cognito Sync dataset.

Quiz

1. What is the main benefit of SAML 2.0 federation?

Question 1 options

2. What are permission sets in AWS IAM Identity Center?

Question 2 options

3. How does OIDC federation differ from SAML federation?

Question 3 options

4. What is the purpose of Cognito identity pools?

Question 4 options

5. How can GitHub Actions assume an IAM role without storing access keys?

Question 5 options

Flashcards

Question

SAML 2.0 Federation

Answer

Enables SSO between a corporate IdP and AWS. Users authenticate with the IdP, receive a SAML assertion, and get temporary AWS credentials.

Question

IAM Identity Center

Answer

Centralized service for managing access to multiple AWS accounts and business applications. Uses permission sets and account assignments.

Question

Permission Set

Answer

A collection of policies defining the level of access users have in a specific AWS account when assigned through Identity Center.

Question

OIDC Federation

Answer

Uses OpenID Connect tokens from external providers to obtain temporary AWS credentials. Supports web/mobile apps and CI/CD like GitHub Actions.

Question

Cognito Identity Pool

Answer

Exchanges identity provider tokens for temporary AWS credentials. Supports authenticated and unauthenticated access with scoped IAM permissions.

Revision Notes

Key Takeaways

  • 1. SAML 2.0 provides enterprise SSO using XML assertions from corporate IdPs
  • 2. IAM Identity Center manages multi-account access with permission sets and account assignments
  • 3. OIDC federation enables web/mobile apps and CI/CD to use external tokens for AWS access
  • 4. Cognito identity pools exchange tokens for temporary AWS credentials
  • 5. Trust policies must specify the IdP as principal and use conditions for security
  • 6. Attribute mapping translates IdP attributes to AWS session names and tags

Interview Tips

  • Describe the SAML flow from user authentication to AWS console access
  • Explain how Identity Center simplifies multi-account management
  • Compare SAML vs OIDC use cases and when to use each
  • Discuss how to secure OIDC federation with conditions on repository, branch, or audience
  • Explain the difference between authenticated and unauthenticated Cognito identity pool access

Cheat Sheet

SAML = enterprise SSO with XML assertions. Identity Center = multi-account access with permission sets. OIDC = JSON tokens for web/mobile/CI-CD. Cognito User Pool = managed user directory. Cognito Identity Pool = token to temp AWS credentials. Trust policy must specify IdP as Principal. Use conditions (sub, aud) to scope OIDC access.