Communitygithub.com

SAMLとAzure ADによるIDフェデレーション構築

オンプレミスのActive Directory(AD FSまたはサードパーティIdP経由)とMicrosoft Entra ID間でSAML 2.0 IDフェデレーションを構成します。フェデレーションモデル(AD FS、パスワードハッシュ同期、パススルー認証、サードパーティIdP)とSAML認証フローをカバーします。オンプレミスの認証権限をクラウドリソースに拡張する場合や、Entra ID向けハイブリッドID SSOアーキテクチャを設計する場合に使用します。

SAMLとAzure ADによるIDフェデレーション構築 とは?

このスキルは、SAML 2.0プロトコルを使用して、組織のオンプレミスActive Directory(AD FS 2019+、またはOktaやPingなどのサードパーティIdP)をMicrosoft Entra ID(旧Azure AD)とフェデレーションする方法を詳細に説明します。主なユースケースは、パスワード同期の必要性を排除し、認証権限をオンプレミスに維持しながら、クラウドリソースやSaaSアプリケーションへのシングルサインオン(SSO)を拡張することです。スキルは、AD FSインフラストラクチャの準備、Entra ID上のフェデレーションドメイン構成、クレームルールの設定、サードパーティSaaSアプリケーションの統合、トークン署名証明書のライフサイクル管理を段階的にカバーしています。PowerShellスクリプトや検証チェックリストを含む実用的な手順を提供し、ハイブリッドID環境でのセキュアで準拠したフェデレーションを実現します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/building-identity-federation-with-saml-azure-ad

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

SAMLとAzure ADによるIDフェデレーション構築 は何をしますか?

概要

IDフェデレーションにより、あるIDプロバイダーで認証されたユーザーが、別のプロバイダーが管理するリソースに、個別の資格情報を維持することなくアクセスできるようになります。このスキルでは、組織のオンプレミスActive Directory(AD FSまたはサードパーティIdP経由)とMicrosoft Entra ID(旧Azure AD)間のSAML 2.0フェデレーションの確立、およびサードパーティSaaSアプリケーション向けのフェデレーションSSOの構成について説明します。フェデレーションにより、パスワード同期に関する懸念が解消され、認証権限をオンプレミスに維持しながら、SSOをクラウドリソースに拡張できます。

使用するタイミング

  • 環境にIDフェデレーション(SAML + Azure AD)機能を展開または構成する場合
  • コンプライアンス要件に合わせたセキュリティ制御を確立する場合
  • このドメインのセキュリティアーキテクチャを構築または改善する場合
  • この実装を必要とするセキュリティ評価を実施する場合

前提条件

  • オンプレミスのActive Directoryドメイン
  • AD FS 2019+、またはサードパーティSAML IdP(Okta、Pingなど)
  • Microsoft Entra IDテナント(P1またはP2ライセンス推奨)
  • Azure AD Connect(バックアップとしてパスワードハッシュ同期を使用するハイブリッドIDの場合)
  • フェデレーションエンドポイント用の公開TLS証明書
  • フェデレーションサービス名のDNSレコード

核となる概念

フェデレーションモデル

モデル認証権限ユースケース
フェデレーション(AD FS)オンプレミスAD FS認証をオンプレミスに維持するという規制要件
マネージド(PHS)パスワードハッシュ同期によるAzure AD最もシンプルなクラウド認証、AD FS不要
マネージド(PTA)パススルーエージェント経由のオンプレミスオンプレミスADに対して検証されるクラウド認証
サードパーティフェデレーション外部IdP(Okta、Ping)マルチIdP環境

SAMLフェデレーションアーキテクチャ

ユーザー → クラウドアプリ(SP)
   │
   └── Azure ADにリダイレクト
          │
          ├── Azure ADがフェデレーションドメインを確認
          │
          └── オンプレミスAD FSにリダイレクト
                 │
                 ├── AD FSがActive Directoryに対して認証
                 │
                 ├── AD FSがSAMLトークンを発行
                 │
                 └── トークンがAzure ADにポストバック
                        │
                        ├── Azure ADがフェデレーション信頼を検証
                        │
                        ├── Azure ADが独自のトークンを発行
                        │
                        └── ユーザーがクラウドアプリのアクセストークンを受信

フェデレーション信頼コンポーネント

コンポーネント説明
トークン署名証明書IdPがSAMLアサーションに署名するために使用するX.509証明書
フェデレーションメタデータIdPのエンドポイントと機能を記述するXMLドキュメント
証明書利用者信頼各SP(Azure AD)に対するAD FSの構成
クレームルールAD属性をSAMLクレームに変換する
発行元URIIdPの一意の識別子(エンティティID)

ワークフロー

ステップ1: AD FSインフラストラクチャの準備

# AD FSロールのインストール
Install-WindowsFeature ADFS-Federation -IncludeManagementTools

# AD FSファームの構成
Install-AdfsFarm `
    -CertificateThumbprint $certThumbprint `
    -FederationServiceDisplayName "Corp Federation Service" `
    -FederationServiceName "fs.corp.example.com" `
    -ServiceAccountCredential $gmsaCredential

# AD FSが動作していることを確認
Get-AdfsProperties | Select-Object HostName, Identifier, FederationPassiveAddress

ステップ2: Azure ADフェデレーションドメインの構成

# Microsoft Graph PowerShellモジュールのインストール
Install-Module Microsoft.Graph -Scope CurrentUser

# Microsoft Graphに接続
Connect-MgGraph -Scopes "Domain.ReadWrite.All"

# マネージドドメインをフェデレーションに変換
# AD FSフェデレーションメタデータ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"
}

# ドメインにフェデレーション設定を適用
New-MgDomainFederationConfiguration -DomainId $domainId -BodyParameter $federationConfig

ステップ3: AD FSクレームルールの構成

# Azure ADの証明書利用者信頼を追加
Add-AdfsRelyingPartyTrust `
    -Name "Microsoft Office 365 Identity Platform" `
    -MetadataUrl "https://nexus.microsoftonline-p.com/federationmetadata/2007-06/federationmetadata.xml"

# クレームルールの構成
$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

ステップ4: サードパーティSaaSフェデレーションの構成

Azure AD経由でSAML SSOをサポートする各SaaSアプリケーションに対して:

  1. Microsoft Entra管理センター > エンタープライズアプリケーションに移動
  2. ギャラリーからアプリケーションを追加(またはカスタムSAMLを作成)
  3. シングルサインオン > SAMLを構成:
    • 識別子(エンティティID): アプリケーションのエンティティID
    • 応答URL (ACS): アプリケーションのアサーションコンシューマサービスURL
    • サインオンURL: アプリケーションのログインURL
  4. ユーザー属性/クレームをマッピング:
    • NameID: user.userprincipalname(電子メール形式)
    • アプリケーションが必要とする追加のクレーム
  5. フェデレーションメタデータXMLまたは証明書をダウンロード
  6. Azure ADのフェデレーション詳細を使用してSaaSアプリを構成

ステップ5: 証明書ライフサイクル管理

AD FSトークン署名証明書は期限切れになるため、更新する必要があります:

# 現在の証明書の有効期限を確認
Get-AdfsCertificate -CertificateType Token-Signing | Select-Object Thumbprint, NotAfter

# AD FSは自動ロールオーバーをサポート(デフォルトで有効)
Get-AdfsProperties | Select-Object AutoCertificateRollover

# 手動ローテーションが必要な場合:
# 1. 新しい証明書をセカンダリとして追加
Set-AdfsCertificate -CertificateType Token-Signing -Thumbprint $newThumbprint -IsPrimary $false
# 2. 新しい証明書でAzure ADを更新
# 3. プライマリに昇格
Set-AdfsCertificate -CertificateType Token-Signing -Thumbprint $newThumbprint -IsPrimary $true
# 4. 古い証明書を削除
Remove-AdfsCertificate -CertificateType Token-Signing -Thumbprint $oldThumbprint

検証チェックリスト

  • AD FSファームが有効なTLSおよびトークン署名証明書で動作している
  • Azure ADドメインが正しいメタデータでフェデレーションとして構成されている
  • クレームルールがAD属性をSAMLアサーションに正しく変換する
  • テストユーザーがフェデレーションフロー全体で認証できる
  • MFAがAD FSまたはAzure AD条件付きアクセスレベルで強制されている
  • 証明書の自動ロールオーバーが有効、または手動ローテーションがスケジュールされている
  • フェデレーションメタデータエンドポイントにパブリックアクセス可能
  • スマートロックアウトがブルートフォースを防ぐように構成されている
  • エクストラネットロックアウトポリシーがAD FSに構成されている
  • AD FSの正常性と証明書の有効期限に対する監視が構成されている
  • ディザスタリカバリ: マネージド認証フォールバックが文書化されている

参考資料

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

関連スキル