- Message Authentification Codeの略
 - メッセージに署名をつけて、認証しようよということ
 - Bearer Tokenと MAC Tokenがある
 - Bearer Tokenの方がシンプルで見かけることが多い
 - Bearer か MACかはクライアントは決めれない。サーバが決める。
 - MAC Tokenでトークンが渡される時のレスポンス
 
HTTP/1.1 200 OK
  Content-Type: application/json
  Cache-Control: no-store
  {
  "access_token":"SlAV32hkKG",
  "token_type":"mac",
  "expires_in":3600,
  "refresh_token":"8xLOxBtZp8",
  "mac_key":"adijq39jdlaska9asud",
  "mac_algorithm":"hmac-sha-256"
  }
- MAC Tokenではリソースへのアクセス時、以下情報をヘッダに付加する必要あり。
 
Authorization: MAC id="h480djs93hd8", ts="1336363200", nonce="dj83hs9s", mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="
- idはトークン取得時にもらった、Mac Key Identifireかaccess_token。
 - tsはクライアントで付け加えるタイムスタンプ
 - nonceはクライアント側で生成し、付け加えるユニークな文字列、id, ts, nonceの組み合わせがユニークにならないといけない
 - macは以下方法で生成
 
ts + nonce + http method + uri + host + port + ext or Authorized(optional) の文字列を生成して、mac_algorithmで指定されているアルゴリズムでhashの生成したもの
参考
http://stackoverflow.com/questions/31209525/oauth-2-0-bearer-tokens-vs-mac-tokens-why-not-using-mac-tokenshttps://dzone.com/articles/oauth-20-bearer-token-profile
https://tools.ietf.org/html/draft-hammer-oauth-v2-mac-token-05
https://www.slideshare.net/ritou/oauth-20-mac-authentication 日本語
0 件のコメント:
コメントを投稿