Open棟梁Project - マイクロソフト系技術情報 Wiki
認可のためのプロトコル。
項番 | 名称 | 実体例 | やること |
1 | ResourceOwner? | ユーザ(人間) | ResourceOwnerのCredentialsを入力してリソースにアクセスする。 |
2 | Client | Program(Webブラウザ, Webアプリケーション, etc.) | 1、3、4を繋ぐ忙しいプログラム(だからクレームベース認証は難しい) |
3 | AuthorizationServer? | 認証・認可のサーバー機能 | 認証チケットとAccess Tokenの発行を行うWebアプリケーション。 |
4 | ResourceServer? | リソースアクセスを提供するサーバー機能、 AuthorizationServer?と別でも良い | Access Tokenを受けてリソースアクセスを提供するWebアプリケーション。 |
+--------+ +---------------+ | |--(A)- Authorization Request ->| Resource | | | | Owner | | |<-(B)-- Authorization Grant ---| | | | +---------------+ | | | | +---------------+ | |--(C)-- Authorization Grant -->| Authorization | | Client | | Server | | |<-(D)----- Access Token -------| | | | +---------------+ | | | | +---------------+ | |--(E)----- Access Token ------>| Resource | | | | Server | | |<-(F)--- Protected Resource ---| | +--------+ +---------------+
ResourceOwner?は、Clientを経由して、AuthorizationServer?(の認証画面)で認証する。
認証後、Clientは、AuthorizationServer?の認可エンドポイントで認可グラントを受け取る。
Clientは、AuthorizationServer?のTokenエンドポイントに認可グラントを提示することで、Access Tokenを要求する.
AuthorizationServer?は、Clientと 認可グラントが正当であれば、ClientにAccess Tokenを発行する。
Clientは、ResourceServer?にAccess Tokenを提示してProtected Resourceにアクセスする。
以下、4つのグラント種別に対応するフローがある。
RFCを読むと、
RFCを読むと、
ResourceOwner?の認証用のCredentialsはOAuth 2.0 仕様の外
(AuthorizationServer?はユーザID、パスワードなどを使用してResourceOwner?を認証)
Clientの認証用のCredentials(AuthorizationServer?はこれらを使用してClientを認証)
URLは仕様で規定されない。
Redirectエンドポイント
認可エンドポイントにGETを送付するときに以下のように指定するパラメタ。
Clientの識別や認証のために、色々な所で使用されるパラメタ。
client_idに対応するRedirectエンドポイントを指定するために指定するパラメタ。
CSRF(Covert Redirect)のセキュリティ対策に使用が推奨されるパラメタ。
セキュリティに関する考察
「OAuth 2.0 の implicit grant flow を認証に使うと、車が通れる程どてかいセキュリティ・ホールが開く。」らしい。
この、セキュリティ・ホールとは、
ザックリ言って、
と言うモノらしい。
この問題に対しては、
以下のように対策できる。
OAuth 2.0仕様には4つのフローが定義されている。
これらのフローのタイプを「グラント種別」と呼ばれる。
以下の様な「グラント種別」がある模様。
+----------+ | Resource | | Owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI ---->| | | User- | | Authorization | | Agent -+----(B)-- User authenticates --->| Server | | | | | | -+----(C)-- Authorization Code ---<| | +-|----|---+ +---------------+ | | ^ v (A) (C) | | | | | | ^ v | | +---------+ | | | |>---(D)-- Authorization Code ---------' | | Client | & Redirection URI | | | | | |<---(E)----- Access Token -------------------' +---------+ (w/ Optional Refresh Token)
Note: The lines illustrating steps (A), (B), and (C) are broken into two parts as they pass through the user-agent.
+----------+ | Resource | | Owner | | | +----------+ ^ | (B) +----|-----+ Client Identifier +---------------+ | -+----(A)-- & Redirection URI --->| | | User- | | Authorization | | Agent -|----(B)-- User authenticates -->| Server | | | | | | |<---(C)--- Redirection URI ----<| | | | with Access Token +---------------+ | | in Fragment | | +---------------+ | |----(D)--- Redirection URI ---->| Web-Hosted | | | without Fragment | Client | | | | Resource | | (F) |<---(E)------- Script ---------<| | | | +---------------+ +-|--------+ | | (A) (G) Access Token | | ^ v +---------+ | | | Client | | | +---------+
Note: The lines illustrating steps (A) and (B) are broken into two parts as they pass through the user-agent.
+----------+ | Resource | | Owner | | | +----------+ v | Resource Owner (A) Password Credentials | v +---------+ +---------------+ | |>--(B)---- Resource Owner ------->| | | | Password Credentials | Authorization | | Client | | Server | | |<--(C)---- Access Token ---------<| | | | (w/ Optional Refresh Token) | | +---------+ +---------------+
+---------+ +---------------+ | | | | | |>--(A)- Client Authentication --->| Authorization | | Client | | Server | | |<--(B)---- Access Token ---------<| | | | | | +---------+ +---------------+
+--------+ +---------------+ | |--(A)- Authorization Request ->| Resource | | | | Owner | | |<-(B)-- Authorization Grant ---| | | | +---------------+ | | | | +---------------+ | |--(C)-- Authorization Grant -->| Authorization | | Client | | Server | | |<-(D)----- Access Token -------| | | | +---------------+ | | | | +---------------+ | |--(E)----- Access Token ------>| Resource | | | | Server | | |<-(F)--- Protected Resource ---| | +--------+ +---------------+