0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RFC 9068 - JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens メモ

Posted at
  • OAuth 2.0アクセストークンのJSON Webトークン(JWT)プロファイルについてメモする。

JWT Access Token Header and Data Structure

ヘッダ

  • alg:必須。JWTトークンの署名アルゴリズムを指定。

データ構造

  • iss,exp,aud,sub,iat,jti(RFC7519参照のこと)などの他、認証情報、アイデンティティ、認可情報などのクレームで構成される。

Requesting a JWT Access Token

  • リクエスト
GET /as/authorization.oauth2?response_type=code
           &client_id=s6BhdRkqt3
           &state=xyz
           &scope=openid%20profile%20reademail
           &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
           &resource=https%3A%2F%2Frs.example.com%2F HTTP/1.1
Host: authorization-server.example.com
  • レスポンス

    • ヘッダー

      {
          "typ":"at+JWT",
          "alg":"RS256",
          "kid":"RjEwOwOA"
      }
      
    • クレーム

      {
              "iss": "https://authorization-server.example.com/",
              "sub": "5ba552d67",
              "aud": "https://rs.example.com/",
              "exp": 1639528912,
              "iat": 1618354090,
              "jti" : "dbe39bf3a3ba4238a513f51d6e1691c4",
              "client_id": "s6BhdRkqt3",
              "scope": "openid profile reademail"
      }
      

Validating JWT Access Tokens

  • 次の流れで検証を行う。
    1. algで指定されたアルゴリズムを使用して、署名を検証する。
      • algが指定されていないトークンは拒否する。
    2. Typヘッダ値がjwtat+JWTまたはapplication/at+jwtであることを確認する。
    3. (JWTアクセストークンが暗号化されている場合、)指定されたキーとアルゴリズムを使用して復号化する。
      • 認可サーバーと暗号化がネゴシエートされていながら、JWTアクセストークンが暗号化されていない場合、そのトークンを拒否する。
    4. 認可サーバーの発行者識別子がissクレームの値と完全一致していることを確認する。
    5. audクレームに有効なリソースインジケーターが含まれているかを確認する。
    6. 現在時刻がexpに指定された値よりも前であることを確認する。
    7. (認可クレームscopeなどが含まれる場合、)リクエストの文脈情報と組み合わせて、リクエストの許可または拒否されるべきかどうかを確認する。

セキュリティに関する考慮事項

  • cross-JWT confusion
    • 傍受したトークンを、所定の⽬的以外の⽬的で使⽤する攻撃。
    • audクレーム値としてユニークな識別子を使用し、個別のリソースに対して同じ発行者によって発行されたアクセストークンを一意に識別する。
  • トークンリクエストに複数のリソースインジケータが含まれている場合、認可サーバーはJWTアクセストークンに含まれる各スコープが、audクレームに関連付けられる特定のリソースと関連があることを確認する。

参考情報

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?