More Related Content
Similar to プロトコルから見るID連携 (20)
More from Naohiro Fujie (20)
プロトコルから見るID連携
- 2. 自己紹介
2
Blog
IdM実験室(Identityに関することを徒然と):http://idmlab.eidentity.p
Social
Facebook Page : eIdentity(Identityに関するFeed):https://www.facebook.com/eidentity
記事
Windowsで構築する、クラウド・サービスと社内システムのSSO環境 (http://www.atmarkit.co.jp/fwin2k/operation/adsf2sso01/adsf2sso01_01.html)
クラウド・サービス連携の基本と最新トレンド (http://www.atmarkit.co.jp/fwin2k/operation/idftrend01/idftrend01_01.html)
開発者にとってのWindows Azure Active Directoryの役割と今後の展開 (http://www.buildinsider.net/enterprise/interviewvittorio/01)
その他
日本ネットワークセキュリティ協会(JNSA)アイデンティティ管理WG(書籍:「クラウド環境におけるアイデ ンティティ管理ガイドライン」etc)
OpenIDFoundation Japan 教育・翻訳WG(OAuth/OpenIDConnect仕様翻訳)、エンタープライズ・アイ デンティティWG
- 3. Agenda
はじめに
ID連携プロトコルとは
AzureAD概要
デモ
ID連携プロトコル解説
ws-federation
SAML2.0
OpenIDConnect
まとめ
3
【ご注意】
本セッションで紹介するID連携プロトコルのフローは あくまでデモシナリオを実行する際のフローなので、 各プロトコルのすべての動きやパラメータを解説す るものではありません。
- 5. 事前信頼
指定
ID連携(フェデレーション)概要
5
認証サーバ
Identity Provider/ IdP
アプリケーション
(Relying Party / RP)
①アクセス
②認証状態チェック
③リダイレクト
④認証指示
⑤認証
⑥トークン発行
ユーザ
信頼できるサーバから 発行されたトークンの 中のID情報を自前のID 情報と紐付ける
⇒SSOの実現
- 7. Identity is the next perimeter
7
FW
企業内ネットワーク(ドメイン)
企業内ネットワーク(ドメイン)
SaaS
アプリ
FW
悪い人
外出中
中の人
協業先
安全
安全
安全
- 8. 単純なシングルサインオン
8
認証サーバ
アプリケーション
アプリケーション
パスワードの分散
システム毎に認証
アプリケーション
パスワードの一元管理
認証Cookieの共有に よるSSO
分散管理状態(SSO不可)
認証サーバの外だし、パスワードの一元管理、 ドメイン内で認証Cookieを共有してSSO
ドメイン境界
- 9. ドメイン境界
ID連携(フェデレーション)
9
認証サーバ
アプリケーション
パスワードの一元管理
認証Cookieの共有に よるSSO
認証サーバの外だし、パスワードの一元管理、 ドメイン内で認証Cookieを共有してSSO
認証サーバ
アプリケーション
パスワードの一元管理
認証サーバの外だし、パスワードの一元管理、 ドメインを跨いだSSO
アプリケーション
ID連携
サーバ
ID連携サーバを経由す ることによるドメイン 間で認証Cookie変換
ドメイン境界
このあたりのやり取り方法を規定したものが ws-federation/SAML/OpenIDConnect
- 10. ポイント①
ID連携をすると、、、
パスワードの分散を防ぐことが出来る
シングルサインオンを実現する
ID連携プロトコルとは、、、
ID情報(認証結果、ユーザ属性など)を安全に伝えるための仕組み
認証そのものを行うためのプロトコルではない
ws-federation / SAML / OpenIDConnectなど
以下の取決めをしたもの
ID情報の表現方法(トークン形式):XMLやJSON
やり取りの方法:HTTP/SOAPの使い方(GET/POSTなど)、パラメータ
10
守るべき個所を少なく出来る
利便性が向上する
- 11. ポイント②
11
プロトコル
主な利用シーン
特徴
ws-federation
今となってはほぼMicrosoftワールド のみ?
Office365⇒AzureAD、AD FS
トークン形式はSAML(XML)を使う(場合が 多い)
HTTP/SOAPベース
ws-*に依存
SAML2.0
エンタープライズの主流
GoogleApps、salesforce.com、 Cybozu、BOX等、多数がサポート
SAMLトークン(XML形式)
HTTP/SOAPベース
OpenIDConnect
コンシューマを中心に拡大中
AzureADやMixi、Yahoo! Japanが サポート
OAuth2.0ベース
トークン形式はJWT(JSON Web Token)
HTTPベース
軽量、実装が簡単
- 14. Azure ADの機能
Identity Provider
ディレクトリサービスとして: Users/Groups (sync with WSAD)
プロトコル・サポート: SAML, ws-federation, OpenIDConnect
外部IdPのサポート: SAML, ws-federation
その他機能: Multi-Factor AuthN, Self-Service Password Reset
Authorization Server
Register WebApps/API as protected resource
14
- 15. Identity Provider
Application
SAML-SP
Application
ws-fed RP
Application
OpenIDConnect RP
Microsoft Account
Azure AD Account
https://login.windows.com
3rdParty
SAML IdP
SAML EndPoint
ws-fed EndPoint
Ext IdPs
RPs
Home
Realm Discover
OAuth2.0
AuthZ/Token
EndPoint
15
- 16. Identity Provider
Application
SAML-SP
Application
ws-fed RP
Application
OpenIDConnect RP
Microsoft Account
Azure AD Account
https://login.windows.com
3rdParty
SAML IdP
SAML EndPoint
ws-fed EndPoint
Ext IdPs
RPs
Home
Realm Discover
OAuth2.0
AuthZ/Token
EndPoint
ws- fed
ws- fed
ws- fed
SAML
ws
res
SAML
SP
16
- 17. Demo
17
Azure ADを中心に各種プロトコルを使ったID 連携を実装したので、まずは動作を確認してみ ましょう。
- 18. 18
デモ環境(AzureVM上に構築)
AD DS
AD FS
AAD Sync改
OpenAM
OpenDJ
Azure AD
Google Apps
Office365
Office365
Google Apps
UserDB
UserDB
UserDB
UserDB
Custom APL
AzureAD/ADFSでSSO
ws-fed
SAML2.0
OpenID
Connect
SAML2.0
LDAP MA
Google Apps MA
AzureADMA
ADDS MA
ws-fed
Sync
Sync
AAD
Prov
OpenAMでSSO
ws-fed
【ご注意】
あくまでデモ用 の環境であり、 一部非サポート の構成を含んで います
- 19. デモシナリオ
ユーザ①(明智光秀/mitsuhidea@xxx.example.com)
AD DSで認証、AD FS経由でAzureADとID連携(ws-federation)
Office365の利用:ws-federation
GoogleAppsの利用:SAML2.0⇒ws-federation変換
ユーザ②(上杉謙信/kenshinu@yyy.example.com)
OpenAMで認証(SAML2.0)でAzureADとID連携
Office365の利用:ws-federation⇒SAML2.0変換
GoogleAppの利用:SAML2.0
カスタムアプリの利用:OpenIDConnect⇒SAML2.0変換
19
※AzureADを経由する際、一旦ws-federationに変換される (login.windows.net⇒login.microsoftonline.com)
- 20. ID連携プロトコル解説 ~ws-federation
20
Office365 / Azure AD / AD FSの間でのID連携 はws-federationを使って行われます。
http://specs.xmlsoap.org/ws/2006/12/federation/ws-federation.pdf
- 21. ①AzureADアプリパネルへアクセス ⇒サインイン画面へリダイレクト
21
シーケンス
アクション
通信内容
リクエスト
アプリケーションポータル へアクセス
GET https://account.activedirectory.windowsazure.com/applications/default.aspx HTTP/1.1
レスポンス
AzureADのログイン画面へ リダイレクト
HTTP/?.?302 Found
Location: https://login.microsoftonline.com/login.srf?wa=wsignin1.0& rpsnv=4&ct=1417169558&rver=6.1.6206.0&wp=MCMBI&wreply=https:%2F%2Faccount.activedirectory.windowsazure.com%2Flanding.aspx%3Ftarget%3D%252fapplications%252fdefault.aspx&lc=1041&id=500633
- 22. ②AzureADのログイン画面へアクセス (サインイン要求)
22
シーケンス
アクション
通信内容
リクエスト
AzureADのログイン画面
GEThttps://login.microsoftonline.com/login.srf?wa=wsignin1.0& rpsnv=4&ct=1417169558&rver=6.1.6206.0&wp=MCMBI&wreply=https:%2F%2Faccount.activedirectory.windowsazure.com%2Flanding.aspx%3Ftarget%3D%252fapplications%252fdefault.aspx&lc=1041&id=500633 HTTP/1.1
パラメータ名
必須
意味
値
wa
○
要求するアクション⇒サインイン
wsignin1.0
wreply
サインインした後、リダイレクト する先のURL⇒アプリパネルのURL
https://account.activedirectory.windowsazure.com/landing.aspx?target=/applications/default.aspx
主要パラメータ⇒サインインして、アプリパネルへ戻す(リダイレクト)
- 23. ③ホームレルムディスカバリによりAD FS サーバへ(AJAX)
23
シーケンス
アクション
通信内容
リクエスト
入力したユーザのドメイン 名よりレルムを取得
GET https://login.microsoftonline.com/GetUserRealm.srf?login= mitsuhidea%40xxx.example.com&handler=1&extended=1 HTTP/1.1
レスポンス
BODYにあらかじめ登録さ れたIdPのURLが返される
{ "State":3, "UserState":2, "Login": "mitsuhidea@xxx.example.com", "FederationGlobalVersion": -1, "DomainName": “XXX.EXAMPLE.COM", "AuthURL": "https://adfs- aadsync.eidentity.local/adfs/ls/?cbcxt=&popupui=&vv=&username=&mkt=&lc=&wfresh=", "SiteGroup": "business", "NameSpaceType": "Federated", "FederationBrandName": "eIdentity", "AuthNForwardType": 0}
- 24. ④AD FSのログイン画面へアクセス (サインイン要求)
24
シーケンス
アクション
通信内容
リクエスト
AD FSのログイン画面
GET https://adfs- aadsync.eidentity.local/adfs/ls/?cbcxt=&popupui=&vv=& username=mitsuhidea%40xxx.example.com&mkt=&lc=1041&wfresh=&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=wa%3Dwsignin1.0%26rpsnv%3D4%26ct%3D1417169558%26rver%3D6.1.6206.0%26wp%3DMCMBI%26wreply%3Dhttps:%252F%252Faccount.activedirectory.windowsazure.com%252Flanding.aspx%253Ftarget%253D%25252fapplications%25252fdefault.aspx%26lc%3D1041%26id%3D500633%26bk%3D1417169560%26LoginOptions%3D3HTTP/1.1
- 25. ④AD FSのログイン画面へアクセス (セキュリティトークン発行要求)
25
パラメータ名
必須
意味
値
wa
○
要求するアクション⇒サインイン
wsignin1.0
wtrealm
○
セキュリティトークンを発行する 対象のレルム(領域)⇒AzureAD(マイクロソフト・オンライン)
wtrealm=urn:federation:MicrosoftOnline
wctx
セキュリティトークンと共に要求 基に返されるコンテキストの値⇒ オリジナルのサインイン要求パラ メータ
wa%3Dwsignin1.0%26rpsnv%3D4%26ct%3D1417169558%26rver%3D6.1.6206.0%26wp%3DMCMBI%26wreply%3Dhttps:%252F%252Faccount.activedirectory.windowsazure.com%252Flanding.aspx%253Ftarget%253D%25252fapplications%25252fdefault.aspx%26lc%3D1041%26id%3D500633%26bk%3D1417169560%26LoginOptions%3D3
主要パラメータ⇒セキュリティトークンを発行して、AzureADへ戻す(リダイレクト)
- 26. ⑤AD FSへログイン(ID/PWDで認証)
26
シーケンス
アクション
通信内容
リクエスト
パスワードの入力
POST https://adfs- aadsync.eidentity.local/adfs/ls/?cbcxt=&popupui=&vv=& username=mitsuhidea%40xxx.example.com&mkt=&lc=1041&wfresh=&wa=wsignin1.0&wtrealm=urn:federation:MicrosoftOnline&wctx=wa%3Dwsignin1.0%26rpsnv%3D4%26ct%3D1417169558%26rver%3D6.1.6206.0%26wp%3DMCMBI%26wreply%3Dhttps:%252F%252Faccount.activedirectory.windowsazure.com%252Flanding.aspx%253Ftarget%253D%25252fapplications%25252fdefault.aspx%26lc%3D1041%26id%3D500633%26bk%3D1417169560%26LoginOptions%3D3 HTTP/1.1
レスポンス
セキュリティトークンを自 動POSTするHTML
次ページ
- 27. 27
<html>
<head>
<title>Working...</title>
</head>
<body>
<form method="POST" name="hiddenform" action="https://login.microsoftonline.com:443/login.srf">
<input type="hidden" name="wa" value="wsignin1.0" />
<input type=“hidden” name=“wresult” value=“<SAMLトークン(次ページ)>" />
<input type="hidden" name="wctx“ value="wa=wsignin1.0&rpsnv=4&ct=1417169558&rver=6.1.6206.0&wp=MCMBI& amp;wreply=https:%2F%2Faccount.activedirectory.windowsazure.com%2Flanding.aspx%3Ftarget%3D%252fapplications%252fdefault.aspx&lc=1041&id=500633&bk=1417169560&LoginOptions=3" />
<noscript>
<p>Script is disabled. Click Submit to continue.</p>
<input type="submit" value="Submit" />
</noscript>
</form>
<script language="javascript">
window.setTimeout('document.forms[0].submit()', 0);
</script>
</body>
</html>
トークンを自動POSTするHTML
JavaScriptで自動POST
- 28. 28
<t:RequestSecurityTokenResponsexmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<t:Lifetime>
<wsu:Createdxmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2014-11-28T10:13:27.035Z
</wsu:Created>
<wsu:Expiresxmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
2014-11-28T11:13:27.035Z
</wsu:Expires>
</t:Lifetime>
<wsp:AppliesToxmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsa:EndpointReferencexmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>urn:federation:MicrosoftOnline</wsa:Address>
</wsa:EndpointReference>
</wsp:AppliesTo>
<t:RequestedSecurityToken>
<saml:AssertionMajorVersion="1" MinorVersion="1" AssertionID="_ba8f8aba-c402-4866-b01e-0a180754e0ef" Issuer="http://adfs-aadsync.eidentity.local/adfs/services/trust"IssueInstant="2014-11-28T10:13:27.035Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:ConditionsNotBefore="2014-11-28T10:13:27.035Z" NotOnOrAfter="2014-11-28T11:13:27.035Z">
<saml:AudienceRestrictionCondition>
<saml:Audience>urn:federation:MicrosoftOnline</saml:Audience>
</saml:AudienceRestrictionCondition>
</saml:Conditions>
セキュリティトークン
(メタ情報)
トークンの適用先
【トークンの本体】
Issuer:発行元
Audience:発行先
- 29. 29
<saml:AttributeStatement>
<saml:Subject>
<saml:NameIdentifierFormat="urn:oasis:names:tc:SAML:1.1:nameid- format:unspecified">mitsuhidea</saml:NameIdentifier>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:AttributeAttributeName="UPN" AttributeNamespace="http://schemas.xmlsoap.org/claims">
<saml:AttributeValue>mitsuhidea@xxx.example.com</saml:AttributeValue>
</saml:Attribute>
<saml:AttributeAttributeName="ImmutableID" AttributeNamespace="http://schemas.microsoft.com/LiveID/Federation/2008/05">
<saml:AttributeValue>mitsuhidea</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
セキュリティトークン
(属性ステートメント)
識別子 (NameIdentifier)
その他属性
UPN、ImmutableID
- 31. 31
<ds:Signaturexmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethodAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ds:ReferenceURI="#_ba8f8aba-c402-4866-b01e-0a180754e0ef">
<ds:Transforms>
<ds:TransformAlgorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:TransformAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>78mg4hvjLPXLB3M1A8z+7ondtFk=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>a6RWe0<署名情報>IbMOw==</ds:SignatureValue>
<KeyInfoxmlns=“http://www.w3.org/2000/09/xmldsig#”>
<X509Data>
<X509Certificate>MIIC9DCC<証明書情報>t/A==
</X509Certificate>
</X509Data>
</KeyInfo>
</ds:Signature>
セキュリティトークン
(署名情報)
トークン署名に
関する情報
- 32. 32
</saml:Assertion>
</t:RequestedSecurityToken>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
</t:RequestSecurityTokenResponse>
セキュリティトークン
(タグ閉じ)
- 33. ⑥AzureADへセキュリティトークンの POST
33
シーケンス
アクション
通信内容
リクエスト
セキュリティトークンの POST(⑤のHTML Formで 自動POST)
POST https://login.microsoftonline.com/login.srf HTTP/1.1
レスポンス
認証Cookieのセットとア プリケーションへのトーク ン情報を自動POSTする HTML
次ページ
- 34. 34
<html>
<head>
<noscript>サインインするにはJavaScript が必要です
<meta http-equiv="Refresh" content="0; URL=https://login.microsoftonline.com/jsDisabled.srf?mkt=JA- JP&lc=1041"/>
</noscript>
<title>続行</title>
<script type="text/javascript">
function OnBack(){}function DoSubmit(){varsubt=false;if(!subt){subt=true;document.fmHF.submit();}}
</script>
</head>
<body onload="javascript:DoSubmit();">
<form name="fmHF" id="fmHF" action="https://account.activedirectory.windowsazure.com/landing.aspx?target=%2fapplications%2fdefault.aspx&wa=wsignin1.0" method="post" target="_top">
<input type=“hidden” name=“t” id=“t” value=“EgAgA<トークン情報>gAAA==">
</form>
</body>
</html>
トークンを自動POSTするHTML
JavaScriptで自動POST
- 35. ⑦アプリケーションへアクセス
35
シーケンス
アクション
通信内容
リクエスト
トークンのPOST(⑥の HTML Formで自動POST)
POST https://account.activedirectory.windowsazure.com/landing.aspx?target=%2fapplications%2fdefault.aspx&wa=wsignin1.0 HTTP/1.1
レスポンス
アプリケーションドメイン での認証Cookieのセット とメインページの表示(リ ダイレクト)
HTTP/?.? 302 Found
Location: /applications/default.aspx
- 36. ID連携プロトコル解説 ~SAML2.0
36
GoogleApps/ Azure AD / OpenAMの間での ID連携はSAML2.0を使って行われます。
http://saml.xml.org/saml-specifications
- 37. ①GoogleAppsへアクセス ⇒ログインサービスへリダイレクト
37
シーケンス
アクション
通信内容
リクエスト
Gmailへアクセス
GET https://mail.google.com/a/yyy.example.com HTTP/1.1
レスポンス
Googleのログインサービ スへリダイレクト
HTTP/?.? 302 Moved Temporarily
Location: https://www.google.com/a/yyy.example.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https:// mail.google.com/a/yyy.example.com/&ss=1<mpl=default<mplcache=2&emr=1
- 38. ②Googleログインサービスへアクセス ⇒OpenAMへリダイレクト
38
シーケンス
アクション
通信内容
リクエスト
Googleのログインサービ スへアクセス
GET https://www.google.com/a/yyy.example.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https:// mail.google.com/a/yyy.example.com/&ss=1<mpl=default<mplcache=2&emr=1 HTTP/1.1
レスポンス
OpenAMのログイン画面 へリダイレクト
HTTP/?.? 302 Moved Temporarily
Location: http://openam.example.com:8080/OpenAM- 11.0.0/SSORedirect/metaAlias/idp?SAMLRequest=fVJ
<SAML認証要求> fQI%3D&RelayState=https%3A%2F%2Fwww.google.com%2Fa%2Fyyy.example.com%2FServiceLogin%3Fservice%3Dmail%26passive%3Dtrue%26r<省略>
- 39. ②Googleログインサービスへアクセス ⇒OpenAMへリダイレクト
39
パラメータ名
必須
意味
値
SAMLRequest
○
SAML認証要求
XMLをBase64エンコードしたもの
(次ページ)
RelayState
サインインした後、リダイレクト する先のURL⇒GoogleAppsのロ グインサービスURL
https://www.google.com/a/yyy.example.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google. com/a/yyy.example.com/&ss=1<mpl=default<mplcache=2&emr=1
主要パラメータ⇒サインインして、GoogleAppsへ戻す(リダイレクト)
- 40. 40
<samlp:AuthnRequestxmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="lmmhgnhkngjibpjfnefeiknjijjjannpjigoahkp"
Version="2.0"
IssueInstant="2014-11-28T23:45:24Z"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
ProviderName="google.com"
IsPassive="false"
AssertionConsumerServiceURL="https://www.google.com/a/yyy.example.com/acs"
>
<saml:Issuerxmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
google.com/a/yyy.example.com
</saml:Issuer>
<samlp:NameIDPolicyAllowCreate="true"
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
/>
</samlp:AuthnRequest>
SAML認証要求
SAMLトークンの受け渡 しの方法(HTTP-POST)
SAMLトークンを渡す先 のURL
認証要求の発行元
SAMLトークンの識別子 のフォーマット
対応する認証リクエスト のID
- 41. ③OpenAMへログイン (ID/PWDで認証)
41
シーケンス
アクション
通信内容
リクエスト
パスワードの入力
POST http://openam.example.com:8080/OpenAM- 11.0.0/UI/Login HTTP/1.1
レスポンス
セキュリティトークンを自 動POSTするHTML
次ページ
- 42. 42
<html>
<head>
<title>Access rights validated</title>
</head>
<body onload="document.forms[0].submit()">
<form method="post" action="https://www.google.com/a/yyy.example.com/acs">
<input type=“hidden” name=“SAMLResponse” value=“PHNh<SAMLトークン(base64エンコード/次ページ)> b25zZT4=" />
<input type="hidden" name="RelayState" value="https://www.google.com/a/yyy.example.com/ServiceLogin?service&# x3d;mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F&ss=1&ltmpl=default&ltmplcache=2&emr=1" />
<noscript>
<center>
<input type="submit" value="Submit SAMLResponsedata " />
</center>
</noscript>
</form>
</body>
</html>
トークンを自動POSTするHTML
JavaScriptで自動POST
- 43. 43
<samlp:Responsexmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
ID="s2d0b3006aa34831878ee2772c0a9b38024e7a141e"
InResponseTo="lmmhgnhkngjibpjfnefeiknjijjjannpjigoahkp"
Version="2.0"
IssueInstant="2014-11-28T23:45:31Z"
Destination="https://www.google.com/a/yyy.example.com/acs"
>
<saml:Issuerxmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
http://openam.example.com:8080/OpenAM-11.0.0
</saml:Issuer>
<samlp:Statusxmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<samlp:StatusCodexmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
Value="urn:oasis:names:tc:SAML:2.0:status:Success"
/>
</samlp:Status>
<saml:Assertionxmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="s251619d0b154c78e42c51b69ffd9a31af5a205691"
IssueInstant="2014-11-28T23:45:31Z"
Version="2.0"
>
<saml:Issuer>http://openam.example.com:8080/OpenAM-11.0.0</saml:Issuer>
SAMLトークン
(メタ情報)
SAML認証要求のID
SAMLトークンの適用先
SAMLトークンの発行元
【トークンの本体】
Issuer:発行元
- 44. 44
<ds:Signaturexmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethodAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ds:ReferenceURI="#s251619d0b154c78e42c51b69ffd9a31af5a205691">
<ds:Transforms>
<ds:TransformAlgorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:TransformAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>Mj7RG98iqvCjsWfU2yIC/aJMLAQ=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>fyjCy<署名>vYHe/Xmk2x+EQ55FdF6+M8ftfTGEBjKztzU+
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIICQD<証明書>gTCkNh</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
SAMLトークン
(署名情報)
トークン署名に
関する情報
- 45. 45
<saml:Subject>
<saml:NameIDFormat="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
NameQualifier="http://openam.example.com:8080/OpenAM-11.0.0"
>kenshinu@yyy.example.com</saml:NameID>
<saml:SubjectConfirmationMethod="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationDataInResponseTo="lmmhgnhkngjibpjfnefeiknjijjjannpjigoahkp"
NotOnOrAfter="2014-11-28T23:55:31Z"
Recipient="https://www.google.com/a/yyy.example.com/acs"
/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:ConditionsNotBefore="2014-11-28T23:35:31Z"
NotOnOrAfter="2014-11-28T23:55:31Z"
>
<saml:AudienceRestriction>
<saml:Audience>google.com/a/yyy.example.com</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
SAMLトークン
(ID情報)
識別子 (NameIdentifier)
トークンの発行先
- 47. ④GoogleAppsのログインサービス へセキュリティトークンのPOST
47
シーケンス
アクション
通信内容
リクエスト
セキュリティトークンの POST(③のHTML Formで 自動POST)
POST https://www.google.com/a/yyy.example.com/acs HTTP/1.1
レスポンス
Googleアカウントの認証 セッション生成ページへの リダイレクト用HTML(自 動GET)
次ページ
- 48. 48
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>リダイレクト中...</title>
<meta http-equiv=“refresh” content=“1;url=https://accounts.google.com/MergeSession?uberauth=Aph<認証情報> o&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F" />
</head>
<body >
<noscript>
<a href=“https://accounts.google.com/MergeSession?uberauth=APh<認証情報> o&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F">続行</a>
</noscript>
<script>
varurl= ‘https:¥x2F¥x2Faccounts.google.com¥x2FMergeSession?uberauth=Aph<認証情報> o¥x26service=mail¥x26continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F';
varparts = (window.location+ '').split('#');
if (parts.length== 2 && parts[1].length > 0) {url+= '#' + parts[1];}
window.setTimeout(function() {
window.location= url;}, 0);
</script>
</body>
</html>
認証セッションの作成
自動リダイレクト
JavaScriptが使えない
環境向け
念のためJavaScriptでも 自動リダイレクト
- 49. ⑤認証セッションの生成
49
シーケンス
アクション
通信内容
リクエスト
認証セッション生成ページ へアクセス
GET https://accounts.google.com/MergeSession?uberauth=APh<認証情報> o&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F HTTP/1.1
レスポンス
CookieチェックURLへリダ イレクト(サービス側処 理)
HTTP/?.? 302 Moved Temporarily
Location: https://accounts.google.com/CheckCookie?chtml=LoginDoneHtml&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F&gidl=CAA
- 50. ⑤認証セッションの生成
50
シーケンス
アクション
通信内容
リクエスト
CookieチェックURLへアク セス
GET https://accounts.google.com/CheckCookie?chtml=LoginDoneHtml&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F&gidl=CAA HTTP/1.1
レスポンス
SIDセットURLへリダイレク ト(サービス側処理)
HTTP/?.? 302 Moved Temporarily
Location: https://accounts.google.co.jp/accounts/SetSID?ssdc=1&sidt=ALW<省略> 3D&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F%3Fauth%3DDQ<省略>Nw
- 51. ⑥アプリケーションへアクセス
51
シーケンス
アクション
通信内容
リクエスト
SIDセットURLへアクセス
GET https://accounts.google.co.jp/accounts/SetSID?ssdc=1&sidt=ALW<省略> 3D&continue=https%3A%2F%2Fmail.google.com%2Fa%2Fyyy.example.com%2F%3Fauth%3DDQ<省略>NwHTTP/1.1
レスポンス
サービス(Gmail)へリダ イレクト
HTTP/?.? 302 Moved Temporarily
Location: https://mail.google.com/a/yyy.example.com/?auth=DQ< 省略>Nw
- 52. ID連携プロトコル解説 ~OpenIDConnect
52
OWIN Security Middlewareを使ってASP.NET アプリケーションをAzure ADとID連携します。
http://openid.net/connect/
日本語訳)http://www.openid.or.jp/document/
- 53. ①外部ログインサービスへアクセス ⇒AzureADへリダイレクト
53
シーケンス
アクション
通信内容
リクエスト
外部ログインサービスへア クセス
POST https://localhost:44308/Account/ExternalLogin HTTP/1.1
レスポンス
AzureADの認可エンドポイ ントへリダイレクト
HTTP/?.? 302 Found
Location: https://login.windows.net/2c62f1a6-<テナントID>ebb1bfff/oauth2/authorize?client_id=bb793<クライアン トID> 86f994e&response_mode=form_post&response_type=code+id_token&scope=openid+profile&state=OpenIdConnect. AuthenticationProperties%3dN<省略>w&nonce=63552819<省略>z
- 54. ②AzureADの認可エンドポイントへ アクセス(code/id_tokenの要求)
54
シーケンス
アクション
通信内容
リクエスト
AzureADの認可エンドポイ ントへアクセス
GET https://login.windows.net/2c62f1<テナントID> 1bfff/oauth2/authorize?client_id=bb79<クライアントID> f994e&response_mode=form_post&response_type=code+id_token&scope=openid+profile&state=OpenIdConnect.AuthenticationProperties%3dN<省略>w&nonce=63552819<省略>z HTTP/1.1
- 55. ②AzureADの認可エンドポイントへ アクセス(code/id_tokenの要求)
55
パラメータ名
必須
意味
値
client_id
○
あらかじめAzureAD上に登録し たアプリケーションの識別子
bb73xxxxxxxxxxxxxxxxxxxx5f994e
(AzureAD上に登録した際に取得した値)
response_mode
code/id_tokenをアプリケー ションに渡す方法
form_post
(SAML等と同じくJavaScriptによるFormから の自動POST)
response_type
○
何を要求するか
code+id_token
(認可コードとIDトークン)
scope
○
発行されるトークンの利用範囲
openid+profile
(認証および基本属性へのアクセス)
主要パラメータ
- 56. ③AzureADでの認証(ws-federation)、 認可コード、IDトークンの発行
56
シーケンス
アクション
通信内容
リクエスト
AzureADでのサインイン要 求
GET https://login.microsoftonline.com/login.srf?wa=wsignin1.0& wtrealm=https%3a%2f%2flogin.windows.net&wreply=https% 3a%2f%2flogin.windows.net%2f2c62<テナントID> bb1bfff%2fwsfederation&wctx=3<省略> 2&wp=MBI_FED_SSL&id= HTTP/1.1
~~省略(ws-federationの流れ)~~
リクエスト
セキュリティトークンの POST
POST https://login.windows.net/2c62f<テナントID>- 0196ebb1bfff/wsfederation HTTP/1.1
レスポンス
認可コード、IDトークンを 自動POSTするHTML
次ページ
- 57. 57
<html>
<head>
<title>Working...</title>
</head>
<body>
<form method="POST" name="hiddenform" action="https://localhost:44308/">
<input type="hidden" name="code" value="AAABA<認可コード>AA" />
<input type="hidden" name="id_token" value="eyJ0eXAiOiJ<IDトークン(Base64/次ページ)>gcjQ0g" />
<input type="hidden" name="state" value="OpenIdConnect.AuthenticationProperties=N9m<省略>iZw" />
<input type="hidden" name="session_state" value="de773cb4-3168-43b1-801d-9d6d32e1bbdf" />
<noscript>
<p>Script is disabled. Click Submit to continue.</p>
<input type="submit" value="Submit" />
</noscript>
</form>
<script language="javascript">window.setTimeout('document.forms[0].submit()', 0);</script>
</body>
</html>
code/id_tokenを自動POST
するHTML
JavaScriptで自動POST
- 58. 58
{
"upn": "nfujie@zzz.onmicrosoft.com",
"family_name": "¥u5bcc¥u58eb¥u69ae",
"unique_name": "nfujie@zzz.onmicrosoft.com",
"ver": "1.0",
"aud": "bb79xxxxxxxxxxxxxxxxxxxxxxxab86f994e",
"pwd_exp": "4082249",
"iss": "https://sts.windows.net/2c62xxxxxxxxxxxxxxxxxxxxbb1bfff/",
"oid": "457ca53f-90ba-4ab9-ba22-b8be363dc73c",
"nonce": "635528194010753013.NTlhNTUwMjYtOWQzOS00YTk3LTg1Y2QtZTVlNTcyOTgxNTM4NzAyY2YwNjAtZmJhZi00ZGE1LTg0ZjMtMDAwYjRlOTQxNzcz",
"pwd_url": "https://portal.microsoftonline.com/ChangePassword.aspx",
"given_name": "¥u5c1a¥u5bdb",
"exp": 1417226211,
"tid": "2c62f1axxxxxxxxxxxxxxxxxxxxxxb1bfff",
"iat": 1417222311,
"amr": [
"pwd"
],
"c_hash": "J_Te2h_v7ogm61niooZxlg",
"nbf": 1417222311,
"sub": "1Nnp-jLjTaoc_K2xVHMiIVNqkCY4JRIN6-alXVC1lkI"
}
IDトークン
認証方式
(パスワード)
識別子
トークンの発行先(アプ リのclient_id)
トークンの発行元 (AzureADテナント)
ID情報
- 59. ④アプリケーションへ認可コード/IDトー クンをPOST
59
シーケンス
アクション
通信内容
リクエスト
code/id_tokenのPOST(③のHTML Formで自動 POST)
POST https://localhost:44308/ HTTP/1.1
レスポンス
外部ログインサービスへリ ダイレクト
HTTP/?.? 302 Found
Location: /Account/ExternalLoginCallback
リクエスト
外部ログインサービスへア クセス
(認証Cookieセット)
GET https://localhost:44308/Account/ExternalLoginCallback HTTP/1.1
レスポンス
アプリケーションの画面
アプリケーションのHTML
- 62. まとめ②
ID連携は基本的に以下のフローで実施される
セキュリティトークン発行要求
パラメータ
どこ(アプリケーションのURI)向けか?
発行後、どこに戻すか(リダイレクト先)
認証
セキュリティトークンの発行
どこで、誰宛に発行されたトークンなのか?
誰に関するセキュリティトークンなのか?
どうやって認証されたのか?
アプリケーションへのセキュリティトークンの引き渡し
62
ws-federation
SAML2.0
OpenIDConnect
wtrealm
audience
aud
wreply
RelayState
redirectUri
issuer
issuer
iss
audience
audience
aud
NameIdentifier
NameIdentifier
sub
AuthenticationMethod
AuthnContextClassRef
amr