「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
強化されたクライアント認証を使用してaccess_tokenを取得する、
(Client Credentialsグラント種別の代替フロー)
↓、RPではなく、Authorization Serverなのでは?と思うが、
使い道に依り、あくまでクライアント認証に用いると考える。
STSによってAssertionを生成する。
Relying Party Client Token Service | | | | | 1) Request Assertion | | |------------------------>| | | | | | 2) Assertion | | |<------------------------| | 3) Assertion | | |<-------------------------| | | | | | 4) OK or Failure | | |------------------------->| | | | | | | |
ローカルでAssertionを生成する。
Relying Party Client | | | | 1) Create | | Assertion | |--------------+ | | | | | 2) Assertion | | |<-------------+ | 3) Assertion | |<-------------------------| | | | 4) OK or Failure | |------------------------->| | | | |
これを使ってアクセストークン・リクエストする。
この文脈上でのアサーションは、
できる。
以下のクレームが必要。
IDトークンが参考になる。
RFC7523のアサーションを参照。
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3AX-bearer& assertion=SAML2 or JWT assertion
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code& code=n0esc3NRze7LTCu7iYzS6a5acc3f0ogp4& client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3AX-bearer& client_assertion=SAML2 or JWT assertion
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials& client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3AX-bearer& client_assertion=SAML2 or JWT assertion
仕様中に明記なし。
HTTP/1.1 400 Bad Request Content-Type: application/json Cache-Control: no-store
{ "error":"invalid_grant", "error_description":"Audience validation failed" }
HTTP/1.1 400 Bad Request Content-Type: application/json Cache-Control: no-store
{ "error":"invalid_client" "error_description":"assertion has expired" }
RFC 7521のアサーションにJWT(JWS)アサーションを使用したもの。
これを使ってアクセストークン・リクエストする。
{"alg": "ES256"、 "kid": "16"}
{ "iss":"https://jwt-idp.example.com", "sub":"mailto:mike@example.com", "aud":"https://jwt-rp.example.net", "nbf":1300815780, "exp":1300819380, "http://claims.example.com/member":true }
{ "alg": "RS256", "typ": "JWT" }
{ "iss":"サービスアカウントのメールアドレス", "scope":"利用するAPIのスコープ", "aud":"https://www.googleapis.com/oauth2/v3/token", "exp":"トークンの有効期限To", "iat":"トークンの有効期限From", }
POST /token.oauth2 HTTP/1.1 Host: as.example.com Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer& assertion=...JWS...
POST /token.oauth2 HTTP/1.1 Host: as.example.com Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code& code=n0esc3NRze7LTCu7iYzS6a5acc3f0ogp4& client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer& client_assertion=...JWS...
仕様中に明記がないが、Googleでのレスポンスは以下の通り。
{ "access_token":"XXXXXXXXXX", "token_type":"bearer", "expires_in":nnnnn }
※ ポイント : refresh_tokenを返さない。
以下を見ると、
通常のOAuth 2.0の
以外に、
クライアント証明書(pfx形式の電子証明書)を使って、
サービスアカウントで認証する方法がある模様。
ちなみに、ここでは、Google.Apis.Analytics Client Libraryに
処理がラッピングされていたため。詳細が不明だったが、
以下を見ると、このClient Libraryの中では、JWTが使用されている模様。
これが、
「JWT bearer token authorizationグラント種別」
の用例である模様。
上記のサイトには、
Service Accounts = JWT Bearer Token Profile
であることが明記されている。
Googleと同様に、以下を見ると、
通常のOAuth 2.0の
以外に、
「JWT bearer token authorizationグラント種別」
をサポートしている模様。
ただし、処理は、ADAL(Active Directory Authentication Library)
にラップされているためJWT作成処理の詳細などを見ることは出来ない。
以下のQiita記事を参照すると、Salesforceは、
の2つのフローをサポートしている模様。
Tags: :認証基盤, :クレームベース認証, :OAuth