building-identity-federation-with-saml-azure-ad skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Configure SAML 2.0 identity federation between on-premises Active Directory (via AD FS or a third-party IdP) and Microsoft Entra ID, covering federation models (AD FS, password hash sync, pass-through auth, third-party IdP) and the SAML authentication flow. Use when extending on-premises authentication authority to cloud resources or designing hybrid identity SSO architecture for Entra ID. Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/building-identity-federation-with-saml-azure-ad/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill building-identity-federation-with-saml-azure-ad, or copy the skill folder into ~/.claude/skills/building-identity-federation-with-saml-azure-ad/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/building-identity-federation-with-saml-azure-ad/SKILL.md

SKILL.md (verbatim)

name: building-identity-federation-with-saml-azure-ad
description: Configure SAML 2.0 identity federation between on-premises Active Directory (via AD FS or a third-party IdP) and Microsoft Entra ID, covering federation models (AD FS, password hash sync, pass-through auth, third-party IdP) and the SAML authentication flow. Use when extending on-premises authentication authority to cloud resources or designing hybrid identity SSO architecture for Entra ID.
domain: cybersecurity
subdomain: identity-access-management
tags:
- saml
- azure-ad
- entra-id
- federation
- identity
- sso
- adfs
- hybrid-identity
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.AA-01
- PR.AA-02
- PR.AA-05
- PR.AA-06
mitre_attack:
- T1606.002
- T1556.007
- T1484.002
- T1078.004
- T1110.003
mitre_f3:
  version: '1.1'
  tactics:
  - initial-access
  - positioning
  techniques:
  - id: F1006
    name: Account Takeover
    tactic: initial-access
    source: f3
  - id: F1006.002
    name: 'Account Takeover: Exposed Login Credential'
    tactic: initial-access
    source: f3
  - id: T1110.003
    name: 'Brute Force: Password Spraying'
    tactic: initial-access
    source: attack
  - id: T1550
    name: Use Alternate Authentication Material
    tactic: initial-access
    source: attack
  - id: F1004
    name: Access with Stolen Session Cookie
    tactic: initial-access
    source: f3

Building Identity Federation with SAML Azure AD

Overview

Identity federation enables users authenticated by one identity provider to access resources managed by another without maintaining separate credentials. This skill covers establishing SAML 2.0 federation between an organization's on-premises Active Directory (via AD FS or third-party IdP) and Microsoft Entra ID (formerly Azure AD), as well as configuring federated SSO for third-party SaaS applications. Federation eliminates password synchronization concerns and keeps authentication authority on-premises while extending SSO to cloud resources.

When to Use

  • When deploying or configuring building identity federation with saml azure ad capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • On-premises Active Directory domain
  • AD FS 2019+ or third-party SAML IdP (Okta, Ping, etc.)
  • Microsoft Entra ID tenant (P1 or P2 license recommended)
  • Azure AD Connect (if using hybrid identity with password hash sync as backup)
  • Public TLS certificate for federation endpoint
  • DNS records for federation service name

Core Concepts

Federation Models

Model Authentication Authority Use Case
Federated (AD FS) On-premises AD FS Regulatory requirement to keep auth on-prem
Managed (PHS) Azure AD with password hash sync Simplest cloud auth, AD FS not needed
Managed (PTA) On-premises via pass-through agent Cloud auth validated against on-prem AD
Third-Party Federation External IdP (Okta, Ping) Multi-IdP environment

SAML Federation Architecture

User → Cloud App (SP)
   │
   └── Redirect to Azure AD
          │
          ├── Azure AD checks federated domain
          │
          └── Redirect to on-premises AD FS
                 │
                 ├── AD FS authenticates against Active Directory
                 │
                 ├── AD FS issues SAML token
                 │
                 └── Token posted back to Azure AD
                        │
                        ├── Azure AD validates federation trust
                        │
                        ├── Azure AD issues its own token
                        │
                        └── User receives access token for cloud app

Federation Trust Components

Component Description
Token-Signing Certificate X.509 certificate used by IdP to sign SAML assertions
Federation Metadata XML document describing IdP endpoints and capabilities
Relying Party Trust Configuration in AD FS for each SP (Azure AD)
Claims Rules Transform AD attributes into SAML claims
Issuer URI Unique identifier for the IdP (entity ID)

Workflow

Step 1: Prepare AD FS Infrastructure

# Install AD FS role
Install-WindowsFeature ADFS-Federation -IncludeManagementTools

# Configure AD FS farm
Install-AdfsFarm `
    -CertificateThumbprint $certThumbprint `
    -FederationServiceDisplayName "Corp Federation Service" `
    -FederationServiceName "fs.corp.example.com" `
    -ServiceAccountCredential $gmsaCredential

# Verify AD FS is operational
Get-AdfsProperties | Select-Object HostName, Identifier, FederationPassiveAddress

Step 2: Configure Azure AD Federated Domain

# Install Microsoft Graph PowerShell module
Install-Module Microsoft.Graph -Scope CurrentUser

# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Domain.ReadWrite.All"

# Convert managed domain to federated
# Using AD FS federation metadata URL
$domainId = "corp.example.com"
$federationConfig = @{
    issuerUri = "http://fs.corp.example.com/adfs/services/trust"
    metadataExchangeUri = "https://fs.corp.example.com/adfs/services/trust/mex"
    passiveSignInUri = "https://fs.corp.example.com/adfs/ls/"
    signOutUri = "https://fs.corp.example.com/adfs/ls/?wa=wsignout1.0"
    signingCertificate = $base64Cert
    preferredAuthenticationProtocol = "saml"
}

# Apply federation settings to domain
New-MgDomainFederationConfiguration -DomainId $domainId -BodyParameter $federationConfig

Step 3: Configure AD FS Claims Rules

# Add Relying Party Trust for Azure AD
Add-AdfsRelyingPartyTrust `
    -Name "Microsoft Office 365 Identity Platform" `
    -MetadataUrl "https://nexus.microsoftonline-p.com/federationmetadata/2007-06/federationmetadata.xml"

# Configure claim rules
$rules = @"
@RuleTemplate = "LdapClaims"
@RuleName = "Extract AD Attributes"
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname",
   Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory",
   types = ("http://schemas.xmlsoap.org/claims/UPN",
            "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",
            "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",
            "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"),
   query = ";userPrincipalName,mail,givenName,sn;{0}",
   param = c.Value);

@RuleTemplate = "PassThroughClaims"
@RuleName = "Pass Through UPN as NameID"
c:[Type == "http://schemas.xmlsoap.org/claims/UPN"]
=> issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
   Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer,
   Value = c.Value,
   ValueType = c.ValueType,
   Properties["http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"]
       = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent");
"@

Set-AdfsRelyingPartyTrust `
    -TargetName "Microsoft Office 365 Identity Platform" `
    -IssuanceTransformRules $rules

Step 4: Configure Third-Party SaaS Federation

For each SaaS application that supports SAML SSO via Azure AD:

  1. Navigate to Microsoft Entra Admin Center > Enterprise Applications
  2. Add the application from the gallery (or create custom SAML)
  3. Configure Single Sign-On > SAML:
    • Identifier (Entity ID): Application's entity ID
    • Reply URL (ACS): Application's assertion consumer service URL
    • Sign-on URL: Application's login URL
  4. Map user attributes/claims:
    • NameID: user.userprincipalname (email format)
    • Additional claims as required by the application
  5. Download the Federation Metadata XML or certificate
  6. Configure the SaaS app with Azure AD's federation details

Step 5: Certificate Lifecycle Management

AD FS token-signing certificates expire and must be renewed:

# Check current certificate expiration
Get-AdfsCertificate -CertificateType Token-Signing | Select-Object Thumbprint, NotAfter

# AD FS supports auto-rollover (enabled by default)
Get-AdfsProperties | Select-Object AutoCertificateRollover

# If manual rotation is needed:
# 1. Add new certificate as secondary
Set-AdfsCertificate -CertificateType Token-Signing -Thumbprint $newThumbprint -IsPrimary $false
# 2. Update Azure AD with new certificate
# 3. Promote to primary
Set-AdfsCertificate -CertificateType Token-Signing -Thumbprint $newThumbprint -IsPrimary $true
# 4. Remove old certificate
Remove-AdfsCertificate -CertificateType Token-Signing -Thumbprint $oldThumbprint

Validation Checklist

  • AD FS farm operational with valid TLS and token-signing certificates
  • Azure AD domain configured as federated with correct metadata
  • Claims rules properly transform AD attributes to SAML assertions
  • Test user can authenticate through federation flow end-to-end
  • MFA enforced at AD FS or Azure AD conditional access level
  • Certificate auto-rollover enabled or manual rotation scheduled
  • Federation metadata endpoint publicly accessible
  • Smart lockout configured to prevent brute force
  • Extranet lockout policies configured on AD FS
  • Monitoring configured for AD FS health and certificate expiry
  • Disaster recovery: managed authentication fallback documented

References

Other files in this skill

assets/template.md (verbatim)

Identity Federation Implementation Template

Federation Details

Setting Value
Azure AD Tenant ID
Federated Domain
AD FS Farm Name
AD FS Service URL https://fs.___/adfs/ls/
Federation Protocol SAML 2.0 / WS-Federation
Backup Auth Password Hash Sync / Pass-Through Auth

AD FS Configuration

Setting Value
AD FS Version
Service Account gMSA recommended
Token-Signing Cert Expiry
Auto-Rollover Enabled Yes / No
WAP Deployed Yes / No

Claims Rules

Rule Name Source Attribute Claim Type Description
UPN userPrincipalName NameID Primary identifier
ImmutableID objectGUID (base64) ImmutableID Azure AD anchor
Email mail emailaddress User email

Validation Results

Test Status Notes
AD FS metadata reachable Pass/Fail
Token-signing certificate valid Pass/Fail
Domain federation configured in Azure AD Pass/Fail
SP-initiated SSO flow Pass/Fail
IdP-initiated SSO flow Pass/Fail
MFA enforcement Pass/Fail
Smart lockout configured Pass/Fail
Sign-in logs showing federated auth Pass/Fail

Disaster Recovery

  • Password hash sync enabled as backup
  • Staged rollout to managed auth tested
  • Break-glass cloud-only admin accounts created
  • AD FS farm disaster recovery plan documented
  • Secondary AD FS farm in DR site (if applicable)

references/api-reference.md (verbatim)

API Reference: SAML Azure AD Federation

Federation Metadata URL

https://login.microsoftonline.com/{tenant-id}/federationmetadata/2007-06/federationmetadata.xml

SAML 2.0 Endpoints

Endpoint URL
SSO (POST) https://login.microsoftonline.com/{tenant}/saml2
SSO (Redirect) https://login.microsoftonline.com/{tenant}/saml2
Logout https://login.microsoftonline.com/{tenant}/saml2

SP Metadata Required Fields

Field Description
entityID SP unique identifier
AssertionConsumerService ACS URL (POST binding)
NameIDFormat emailAddress or persistent
SingleLogoutService SLO URL (optional)

XML Namespaces

ns = {
    "md": "urn:oasis:names:tc:SAML:2.0:metadata",
    "ds": "http://www.w3.org/2000/09/xmldsig#",
    "saml": "urn:oasis:names:tc:SAML:2.0:assertion",
}

SAML Bindings

Binding URI
HTTP-POST urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
HTTP-Redirect urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect
SOAP urn:oasis:names:tc:SAML:2.0:bindings:SOAP

Azure AD Graph API (App Registration)

POST https://graph.microsoft.com/v1.0/servicePrincipals
Authorization: Bearer TOKEN
{
  "appId": "app-id",
  "preferredSingleSignOnMode": "saml",
  "loginUrl": "https://app.example.com/login"
}

Validation Checks

Check Severity
HTTPS on ACS URL High
Certificate present Critical
HTTP-POST binding available Medium
NameID format configured Medium

references/standards.md (verbatim)

Identity Federation with SAML Azure AD - Standards Reference

Federation Protocols

SAML 2.0 (OASIS)

  • Security Assertion Markup Language version 2.0
  • XML-based framework for exchanging authentication/authorization data
  • Profiles: Web Browser SSO, Enhanced Client or Proxy, Single Logout
  • Bindings: HTTP Redirect, HTTP POST, HTTP Artifact, SOAP

WS-Federation (OASIS)

  • Web Services Federation Language
  • Used by AD FS for passive federation (browser-based)
  • Token types: SAML 1.1, SAML 2.0

OpenID Connect

  • Built on OAuth 2.0
  • JSON/REST-based (vs. SAML XML)
  • Used by Azure AD as primary protocol for modern applications
  • JWT tokens instead of SAML assertions

Microsoft Entra ID Federation Requirements

Supported Federation Protocols

Protocol Use Case Token Format
SAML 2.0 Enterprise SSO, third-party apps SAML assertion (XML)
WS-Federation Legacy applications, AD FS SAML token
OpenID Connect Modern web/mobile apps JWT

Domain Federation Requirements

  • Domain must be verified in Azure AD
  • Only one federation configuration per domain
  • Password hash sync recommended as backup
  • Azure AD Connect for hybrid identity sync

Compliance Mapping

NIST SP 800-63C - Federation and Assertions

  • FAL1: Bearer assertion, direct presentation
  • FAL2: Bearer assertion with additional security
  • FAL3: Holder-of-key assertion

FedRAMP

  • IA-2: Identification and Authentication
  • IA-5: Authenticator Management
  • IA-8: Identification and Authentication (Non-Organizational Users)
  • Federation required for cross-organization access

ISO 27001:2022

  • A.5.16: Identity management
  • A.5.17: Authentication information
  • A.8.5: Secure authentication

references/workflows.md (verbatim)

Identity Federation with SAML Azure AD - Workflows

Federation Setup Workflow

Phase 1: PREREQUISITES
    ├── Verify domain ownership in Azure AD
    ├── Install and configure Azure AD Connect for user sync
    ├── Deploy AD FS farm (if using on-premises federation)
    ├── Obtain public TLS certificate for federation endpoint
    └── Configure DNS for federation service name

Phase 2: FEDERATION CONFIGURATION
    ├── Configure AD FS relying party trust for Azure AD
    ├── Set up claims issuance rules (UPN, ImmutableID)
    ├── Convert Azure AD domain from managed to federated
    ├── Verify federation with Test-MgDomainFederationConfiguration
    └── Test user sign-in through federation flow

Phase 3: APPLICATION SSO
    ├── Add SaaS applications to Azure AD enterprise apps
    ├── Configure SAML SSO for each application
    ├── Map user attributes and claims
    ├── Test SSO for each application
    └── Assign users/groups to applications

Phase 4: SECURITY HARDENING
    ├── Enable conditional access policies
    ├── Configure MFA at AD FS or Azure AD level
    ├── Enable smart lockout and extranet lockout
    ├── Set up certificate auto-rollover
    └── Forward AD FS audit logs to SIEM

SAML Authentication Flow (Federated Domain)

User accesses cloud application
    │
    ├── Application redirects to Azure AD
    │   (Azure AD acts as IdP for the application)
    │
    ├── Azure AD identifies user's domain as federated
    │
    ├── Azure AD redirects user to on-premises AD FS
    │   (AD FS is the IdP for the federated domain)
    │
    ├── AD FS authenticates user against Active Directory:
    │   ├── Kerberos (if on corporate network)
    │   ├── Forms-based authentication (if external)
    │   └── MFA challenge (if configured)
    │
    ├── AD FS issues SAML assertion with claims:
    │   ├── UPN (user principal name)
    │   ├── ImmutableID (objectGUID base64-encoded)
    │   ├── Email, display name, groups
    │   └── Signed with token-signing certificate
    │
    ├── SAML assertion posted to Azure AD
    │
    ├── Azure AD validates assertion:
    │   ├── Verify signature against known AD FS certificate
    │   ├── Match ImmutableID to synced user
    │   ├── Apply conditional access policies
    │   └── Issue Azure AD token for the application
    │
    └── User accesses the cloud application

Failover Workflow (AD FS Outage)

AD FS becomes unavailable
    │
    ├── Users cannot authenticate through federation
    │
    ├── OPTION 1: Staged Rollout to Managed Authentication
    │   ├── Enable password hash sync as backup (should already be active)
    │   ├── Use Azure AD staged rollout to move groups to managed auth
    │   └── Users authenticate directly with Azure AD (password hash)
    │
    ├── OPTION 2: Convert Domain to Managed
    │   ├── Run: Convert-MgDomainToManaged (emergency procedure)
    │   ├── All users switch to Azure AD authentication
    │   └── Requires password hash sync to be active
    │
    └── After AD FS restored:
        ├── Re-establish federation trust
        ├── Convert domain back to federated
        └── Verify authentication flow

Certificate Rotation Workflow

AD FS token-signing certificate approaching expiry
    │
    ├── Auto-Rollover Enabled (recommended):
    │   ├── AD FS generates new certificate 20 days before expiry
    │   ├── New cert is added as secondary
    │   ├── Azure AD automatically picks up via metadata refresh
    │   ├── New cert promoted to primary at expiry
    │   └── Old cert removed after grace period
    │
    └── Manual Rotation:
        ├── Generate new signing certificate in AD FS
        ├── Add as secondary: Set-AdfsCertificate ... -IsPrimary $false
        ├── Update Azure AD: Update-MgDomainFederationConfiguration
        ├── Wait for replication (allow 24-48 hours)
        ├── Promote to primary: Set-AdfsCertificate ... -IsPrimary $true
        └── Remove old certificate

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.