マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。

目次

概要

特徴

モジュラーデザイン

ユースケースに対応するため、

多様な環境をサポートできる。

プロトコル概要

ざっくり、リクエスト→認証・認可→ユーザ情報を取得。

+--------+                                   +--------+
|        |                                   |        |
|        |---------(1) AuthN Request-------->|        |
|        |                                   |        |
|        |  +--------+                       |        |
|        |  |        |                       |        |
|        |  |  End-  |<--(2) AuthN & AuthZ-->|        |
|        |  |  User  |                       |        |
|   RP   |  |        |                       |   OP   |
|        |  +--------+                       |        |
|        |                                   |        |
|        |<--------(3) AuthN Response--------|        |
|        |                                   |        |
|        |---------(4) UserInfo Request----->|        |
|        |                                   |        |
|        |<--------(5) UserInfo Response-----|        |
|        |                                   |        |
+--------+                                   +--------+

OAuth 2.0への認証拡張

OAuth 2.0との違いは、認証拡張機能が追加実装された点にある。

仕様の柱

フロー

OAuth 2.0に認証結果とプロフィールの受渡し機能を追加。

ID トークン

追加のエンドポイント

フロー

Authorization Code Flow

概要

OAuth 2.0 からのステップ上の拡張部分は無い。

ただし、

ステップ

朱書きは、OAuth 2.0 からのステップ上の変更・拡張部分。

The Authorization Code Flow goes through the following steps.

  1. Client prepares an Authentication Request containing the desired request parameters.
  2. Client sends the request to the Authorization Server.
  3. Authorization Server Authenticates the End-User.
  4. Authorization Server obtains End-User Consent/Authorization.
  5. Authorization Server sends the End-User back to the Client with an Authorization Code.
  6. Client requests a response using the Authorization Code at the Token Endpoint.
  7. Client receives a response that contains an ID Token and Access Token in the response body.
  8. Client validates the ID token and retrieves the End-User's Subject Identifier.

Implicit Flow

概要

ステップ

朱書きは、OAuth 2.0 からのステップ上の変更・拡張部分。

The Implicit Flow follows the following steps:

  1. Client prepares an Authentication Request containing the desired request parameters.
  2. Client sends the request to the Authorization Server.
  3. Authorization Server Authenticates the End-User.
  4. Authorization Server obtains End-User Consent/Authorization.
  5. Authorization Server sends the End-User back to the Client with an ID Token and, if requested, an Access Token.
  6. Client validates the ID token and retrieves the End-User's Subject Identifier.

Hybrid Flow

概要

ID トークンと同時に、アクセストークンや認可コードが一緒に発行される。

ステップ

朱書きは、Authorization Code Flowとの差異。

The Hybrid Flow follows the following steps:

  1. Client prepares an Authentication Request containing the desired request parameters.
  2. Client sends the request to the Authorization Server.
  3. Authorization Server Authenticates the End-User.
  4. Authorization Server obtains End-User Consent/Authorization.
  5. Authorization Server sends the End-User back to the Client with an Authorization Code and,
    depending on the Response Type, one or more additional parameters.
  6. Client requests a response using the Authorization Code at the Token Endpoint.
  7. Client receives a response that contains an ID Token and Access Token in the response body.
  8. Client validates the ID Token and retrieves the End-User's Subject Identifier.

ポイント

IDトークン

概要

クレームセット

必須クレーム群

ケースバイケースなクレーム群

オプションのクレーム群

Hybrid Flowのクレーム

Hybrid Flowの場合、以下が必須。

ユーザー属性クレーム群

その他、ユーザー属性クレーム群を格納する。

外部クレーム

Idp(OP)は、扱うクレームの内容によって、

どちらを利用すべきかを判断する必要がある。

集約クレーム(Aggregated Claims)

一定期間変更されないことが保証されており
キャッシュの効果があるものは集約クレーム。

分散クレーム(Distributed Claims)

クレームそのものではなく、問い合わせ先のURLを扱う。

をレスポンスに含む。

頻繁に更新されるものは分散クレーム。

Google

GoogleでOpenID Connectの認証で取得したクレームセット。
(id_tokenそのものなのか?、ユーザー情報エンドポイントから取得したクレームか?)

{
  "iss":"accounts.google.com",
  "at_hash":"・・・", ← Hybrid Flowの追加クレーム
  "email_verified":"true",
  "sub":"ユーザーの一意識別子",
  "azp":"認可された対象者のID.apps.googleusercontent.com",
  "email":"・・・・",
  "aud":"クライアント識別子.apps.googleusercontent.com",
  "iat":JWT の発行日時(Unix時間),
  "exp":JWT の有効期限(Unix時間)
}

ココを見ると、これは恐らく、id_tokenなのだろうなと。

以下のGoogle公式のマニュアルにも記載があった。

ユーザー属性クレーム群

Standard Claims

項番グループ名意味
クレーム名
1subユーザーの一意識別子
2profileプロフィール
2-1nameフルネーム
2-2given_name
2-3family_name
2-4middle_nameミドルネーム
2-5nicknameニックネーム
2-6preferred_username好みのユーザー名
2-7profileプロフィールページの URL
2-8pictureプロフィール画像の URL
2-9websiteWeb サイトやブログの URL
2-10gender性別。female と male が定義済み。
2-11birthdate誕生日。YYYY-MM-DD。
2-12zoneinfoタイムゾーン。Europe/Paris など。
2-13localeロケール。en-US など。
2-14updated_at情報最終更新日。Unix エポックからの経過秒数。
3email電子メール
3-1email電子メールアドレス
3-2email_verified電子メールアドレスが検証済みか否かの真偽値
4phone電話
4-1phone_number電話番号
4-2phone_number_verified電話番号が検証済みか否かの真偽値
5address住所 JSON object。書式は「5.1.1. Address Claim」に記載。
5-1formattedフォーマットされたフルメールアドレス、表示用・郵送用に使用
5-2street_address通り・番地、号室、私書箱、複数行の拡張された住所情報。
5-3localityCity or locality
5-4regionState, province, prefecture, or region.
5-5postal_codeZip code or postal code
5-6countryCountry name

多言語化

ユーザー属性クレーム群の格納要求

scope値による格納要求

scope値によってユーザー属性クレーム群の格納要求を行うことができる。

グループ名

前述のグループ名(profile, email, phone, address)をscope値に指定可能。

格納部位

クレーム要求JSONによる格納要求

トップレベルメンバ

クレーム要求JSONの例

クレーム要求JSONの例を以下に示す:

 {
  "userinfo":
   {
    "given_name": {"essential": true},
    "nickname": null,
    "email": {"essential": true},
    "email_verified": {"essential": true},
    "picture": null,
    "http://example.info/claims/groups": null
   },
  "id_token":
   {
    "auth_time": {"essential": true},
    "acr": {"values": ["urn:mace:incommon:iap:silver"] }
   }
 }

ユーザー情報エンドポイント

概要

リクエスト

レスポンス

Discovery、Dynamic Client Registrationとの関連

この仕様は、Discovery、Dynamic Client Registrationと関係がある。

その他

比較的、重要度の高い仕様についてまとめる。

claimsリクエスト・パラメタ

認証コンテキストクラス

識別子

Authentication Context Class Reference(ACR)識別子。

要求方法

arcクレームをscopeやclaimsリクエスト・パラメタで要求できる。

参考

https://qiita.com/TakahikoKawasaki/items/185d34814eb9f7ac7ef3#16-%E8%AA%8D%E8%A8%BC%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%82%AF%E3%83%A9%E3%82%B9

リクエスト・オブジェクト

認可エンドポイントに渡すリクエスト・パラメタ群を
JWT形式(認証要求に署名し、オプションで暗号化できる)で渡す方法。

渡し方

処理

参考

参考

OpenID Foundation

Client Implementer's Guide

WebアプリケーションのClientに当該フローを実装する場合の実装ガイド。

関連仕様

IdM実験室

WIF

WIF Extension for OAuthは古い?

OWIN

Microsoft.Owin.Security.OpenIdConnect?

ADFS

Microsoft Azure Active Directory

OpenID Connectのシーケンス

STEP 0 は事前準備なので、STEP 1 からが実際の認証・認可のシーケンス。

Webアプリ(Basic Client Profile)

モバイルアプリ(Implicit Client Profile)

結果的に、OPからRP識別のための“cient_id”がレスポンスされる。

OpenId? Connectのサンプル

Microsoft.Owin.Security.OpenIdConnect?

AzureADに対して、OpenId? Connectを使用して認証する。

https://github.com/OpenTouryoProject/SampleProgram/tree/master/ASPNET/OpenID_Connect/


Tags: :認証基盤, :クレームベース認証


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS