1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Google WorkspaceをIDPとしたEntraIDへのSSO

Last updated at Posted at 2025-10-04

この記事は人間が書きました。

EntraIDをIDPとしたSSO設定の記事は多く見られますが、Google WorkspaceをIDPとしてEntraIDとのSSOを設定している記事はあまり見ない気がするため、設定手順を記録しておきます。基本的には以下のドキュメントの手順通りですが、証明書の更新作業についても併せて説明します。

前提

GoogleWorkspaceと同ドメイン名でEntraIDのカスタムドメイン設定が済んでいることが前提です。設定がまだの場合は、以下のドキュメントを参照して設定を完了させます。

GoogleWorkspace側の設定

Google Workspace 管理コンソールへアクセスします。
1: [アプリ] > [ウェブアプリとモバイルアプリ] > [アプリを追加]
2: [検索] > [Microsoft Office 365 ウェブ(SAML)] を選択
3: アプリの追加後、IDPメタデータをダウンロード

4: サービスのステータス:(すべてのユーザー)をON
5: サービスプロパイダの詳細

  • 署名付き応答にチェック
  • 名前IDの形式: PERSISTENT
  • 名前ID: Basic Information > Primary email)

image.png

6: SAML属性のマッピング

  • GoogleDirectoryの属性: Primary emailIDPEmail
    image.png

EntraID側の設定

Azureにグローバル管理者権限でログインします。
ここからPoweShellコマンドを打つ必要がありますが、CloudShellが楽なのでCloudShellを起動します。※ポータル上部のここから起動
6.png

1: 先程ダウンロードしたXMLファイルをアップロード
image.png

2: 以下コマンドで検証済みのドメインをフェデレーションに切替

powershell
Install-Module Microsoft.Graph -Scope CurrentUser
Import-Module Microsoft.Graph

$domainId = "<domain name>"

# cloudshellにアップロードしたxmlファイルを読込
$xml = [Xml](Get-Content GoogleIDPMetadata.xml)
$cert = -join $xml.EntityDescriptor.IDPSSODescriptor.KeyDescriptor.KeyInfo.X509Data.X509Certificate.Split()

$issuerUri = $xml.EntityDescriptor.entityID
$signinUri = $xml.EntityDescriptor.IDPSSODescriptor.SingleSignOnService | ? { $_.Binding.Contains('Redirect') } | % { $_.Location }
$signoutUri = "https://accounts.google.com/logout"
$displayName = "Google Workspace Identity"

#認証が走る
Connect-MGGraph -Scopes "Domain.ReadWrite.All","Directory.AccessAsUser.All"

#パラメータをセット
$domainAuthParams = @{
  DomainId = $domainId
  IssuerUri = $issuerUri
  DisplayName = $displayName
  ActiveSignInUri = $signinUri
  PassiveSignInUri = $signinUri
  SignOutUri = $signoutUri
  SigningCertificate = $cert
  PreferredAuthenticationProtocol = "saml"
  federatedIdpMfaBehavior = "acceptIfMfaDoneByFederatedIdp"
}
#確認
$domainAuthParams

#設定
New-MgDomainFederationConfiguration @domainAuthParams

#設定確認
Get-MgDomainFederationConfiguration -DomainId $domainId | fl

#もしフェデレーション解除する場合は以下
$domain = "<domain>"
$feds = Get-MgDomainFederationConfiguration -DomainId $domain
$fedId = ($feds.Id -split "/")[-1]
Remove-MgDomainFederationConfiguration -DomainId $domain -InternalDomainFederationId $fedId

ユーザーを追加してSSOできるか確認

EntraIDにユーザーを追加します。
ユーザー追加する際にポータル画面からではimmutableIDを付与することができないため、コマンドで追加していきます。

powershell
$displayName = "山田花子"# 表示名
$userAlias = "hanako_yamada"
$domain = "<domain>"
$upn = "$userAlias@$domain"
$password = "P@ssw0rd" + (Get-Random -Minimum 100 -Maximum 999)

$userParams = @{
    DisplayName = $displayName
    UserPrincipalName = $upn
    MailNickname = $userAlias
    AccountEnabled = $true
    OnPremisesImmutableId = $upn
    PasswordProfile = @{
        Password = $password
        ForceChangePasswordNextSignIn = $true
    }
}

# ユーザー作成
$newUser = New-MgUser @userParams

# 既存ユーザーにimmutableIDを付与する場合は以下
Update-MgUser -UserId $upn -OnPremisesImmutableId $upn

そして、追加したIDでAzureにログインして確認します。
Googleの認証画面にリダイレクトし、認証後にAzureポータルへアクセスできるはずです。
Googleでの認証後に認証画面のループが発生した場合は、https://accounts.google.com/Logout から一度サインアウトして再ログインすることで解消できました。

※証明書更新時

証明書を更新する際は以下のコマンドを使用しました。

powershell
Connect-MgGraph -Scopes "Domain.ReadWrite.All"

$domain = "<domain>"           
$fed = Get-MgDomainFederationConfiguration -DomainId $domain
$fid = $fed.Id                                              

# 新しい証明書を一行で読み込む
$cert = (Get-Content Google_xxx-xx-xx_SAML2_0.pem | Where-Object {$_ -notmatch "-----BEGIN" -and $_ -notmatch "-----END"} ) -join ""

#更新
Update-MgDomainFederationConfiguration -DomainId $domain -InternalDomainFederationId $fid -SigningCertificate $cert

おわりに

設定後に認証画面ループが発生したので少し焦りました。
いずれにせよSSOはいいですね。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?