Google Workspacesを使い、GitHubにログインする方法(シングルサインオン SSO SAML)

GitHub Business クラウド アプリケーション - Google Workspace 管理者 ヘルプ

上記URL先のやり方で簡単に出来た。

GitHubの方を月21ドル/人のプランに変更する必要あり。

※ 手順2の前に、手順3をする必要あり。

※ シークレットウィンドウで開く必要は無さそう。

 

 

 

 

手順 1: GoogleSAML ID プロバイダ(IdP)として設定する
Google 管理コンソール(admin.google.com)で次の操作を行います。
メニュー アイコン "" 次に "" [アプリ] > [ウェブアプリとモバイルアプリ] にアクセスします。
[アプリを追加] 次に [アプリを検索] をクリックします。
検索欄に「GitHub Business」と入力します。
検索結果で、GitHub Business SAML アプリにカーソルを合わせ、[選択] をクリックします。

https://admin.google.com/ac/apps/saml/xxxxxxxxxxxxxxx

[Google ID プロバイダの詳細] ページで、次の操作を行います。
[SSO の URL] の値をコピーして保存します。
[エンティティ ID] の値をコピーして保存します。
証明書をダウンロードします。
[続行] をクリックします。
[サービス プロバイダの詳細] ページで、[ACS の URL] と [エンティティ ID] の {your-organization} を GitHub Business の組織名に置き換えます。
[続行] をクリックします。

 

ちなみに、「証明書を管理」をクリックすると、SSOのURLと、エンティティIDが出てくる。

SSO の URL
https://accounts.google.com/o/saml2/idp?idpid=xxxxxxxxx

エンティティ ID
https://accounts.google.com/o/saml2?idpid=xxxxxxxxx

 

 

 

手順 2: GitHub Business を SAML 2.0 のサービス プロバイダ(SP)として設定する
新しいシークレット ブラウザ ウィンドウを開きます。
組織の管理者アカウントで GitHub Business にログインします。
右上のユーザー名をクリックし、[Settings] を選択します。
左側のメニューの [Organization settings] で、組織名をクリックします。
[Organization settings] で、[Security] をクリックします。
[SAML single sign-on] の各項目に、手順 1 でコピーした情報を入力します。
Sign on URL: SSO の URL
Issuer: エンティティ ID
Public certificate: 証明書
[Test SAML configuration] をクリックして設定を確認します。
SAML 設定セクションの上部にある [Enable SAML authentication] をオンにします。
[Save] をクリックします。

 

 

完了した後は、以下のリンクからリカバリコードをダウンロードしておいた方がいい。

証明書が有効期限切れになると、誰もログインできなくなる。

それでカスタマーサポートに連絡して、SSOを解除してもらった過去がある。

Save your recovery codes in a safe place. 

 

 

SSOを必須条件にする場合、事前に各ユーザがログインした上で、

「Authenticate your account」ボタンを押して、シングルサインオンを有効化しないといけない。事前に各ユーザがSSOを一度認証しておかないと、各ユーザが削除されるとのアラートが表示される。

Single sign-on has been enabled for xxxx

https://github.com/orgs/xxxxxxxxx/sso

 

Require SAML SSO authentication for all members of the xxxxxxxxInc. organization.
Requiring SAML SSO will remove all members (excluding outside collaborators) who have not authenticated their accounts. Members will receive an email notifying them about the change. Leaving this option unchecked will allow you to test before requiring.

 

 

 

 

 

 

 

 

これはあまり読んでないけど参考情報

SAMLシングルサインオンで認証する - GitHub Docs

 

いくつか実験をしてみた。

1. GitHubにログインしてない状態でSSOを実行 ⇒ 403エラー画面

 Error: app_not_enabled_for_user

 Service is not enabled for this user.

2. GitHubにログインをしてOrganizationページを表示 ⇒ SSO認証に遷移

3. Organizationへのアクセス権のないユーザでGitHubにログインをしてOrganizationページを表示 ⇒ GitHubの404エラー画面

 This is not the web page you are looking for.

4. Organizationへのアクセス権のないユーザでGitHubにログインをしてSSOを実行 ⇒ 403エラー画面

 Error: app_not_enabled_for_user

 Service is not enabled for this user.

 

つまり、OrganizationにアクセスできるユーザでGitHubにログイン状態 且つ SSO認証を通す ⇒ Organizationページに遷移できる。ということらしい。

 

 

SSH接続すると、エラーになる。

ERROR: The `Organization_Name' organization has enabled or enforced SAML SSO. To access
this repository, you must use the HTTPS remote with a personal access token
or SSH with an SSH key and passphrase
that has been authorized for this organization. Visit
https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/ for more information.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

SSHキーに対してSSOを有効化する必要があるみたい。

SAMLシングルサインオンで利用するためにSSHキーを認可する - GitHub Docs

https://github.com/settings/keys

 

これでSSH接続でもOrganizationのレポジトリに接続できるようになりました。