
概要
クライアントやその他のシステムから受信した JWT の署名を検証します。また、このポリシーはクレームを抽出してコンテキスト変数に格納し、後続のポリシーまたは条件でそれらの値を調べて、認可やルーティングを決定できるようにします。詳しくは、JWS ポリシーと JWT ポリシーの概要をご覧ください。
このポリシーが実行されると、Edge は JWT の署名を検証し、有効期限と開始時期に基づいて JWT が有効であることを検証します。このポリシーは、必要に応じて subject や issuer、audience、追加クレームの値など、JWT の特定クレームの値を検証することもできます。
検証の結果 JWT が有効である場合、JWT に含まれるすべてのクレームが抽出されて後続のポリシーや条件で使用できるようにコンテキスト変数に格納され、リクエストの続行が許可されます。JWT の署名を検証できない場合、タイムスタンプが原因で JWT が無効となった場合、すべての処理が停止し、レスポンスでエラーが返されます。
JWT の各部について、またその暗号化と署名の方法については、RFC7519 をご覧ください。
動画
JWT の署名を検証する方法についての動画をご覧ください。
サンプル
HS256 アルゴリズムで署名された JWT の検証
このポリシー サンプルでは、HS256 暗号化アルゴリズム(SHA-256 チェックサムを使用した HMAC)で署名された JWT を検証します。JWT は、jwt
という名前のフォーム パラメータを介してプロキシ リクエスト内で渡されます。キーは private.secretkey
という名前の変数に含まれています。ポリシーに対してリクエストする方法など、詳しい例については上記の動画をご覧ください。
ポリシーの構成には JWT のデコード(復号)と評価に必要な情報を含めます。たとえば、JWT の場所(Source 要素に指定されたフロー変数内)、検証に必要な署名アルゴリズム、秘密鍵の場所(Edge フロー変数に保存され、Edge KVM などから取得可能)、必要なクレームとその値のセットなどです。
<VerifyJWT name="JWT-Verify-HS256"> <DisplayName>JWT Verify HS256</DisplayName> <Algorithm>HS256</Algorithm> <Source>request.formparam.jwt</Source> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <SecretKey> <Value ref="private.secretkey"/> </SecretKey> <Subject>monty-pythons-flying-circus</Subject> <Issuer>urn://apigee-edge-JWT-policy-test</Issuer> <Audience>fans</Audience> <AdditionalClaims> <Claim name="show">And now for something completely different.</Claim> </AdditionalClaims> </VerifyJWT>
ポリシーは出力をコンテキスト変数に書き込み、後続のポリシーまたは API プロキシの条件でその値を調べられるようにします。このポリシーの変数のリストについては、フロー変数をご覧ください。
RS256 アルゴリズムで署名された JWT の検証
このポリシー サンプルでは、RS256 アルゴリズムで署名された JWT を検証します。検証するには公開鍵を用意する必要があります。JWT は、jwt
という名前のフォーム パラメータを介してプロキシ リクエスト内で渡されます。公開鍵は public.publickey
という名前の変数に格納されます。ポリシーに対してリクエストする方法など、詳しい例については上記の動画をご覧ください。
このサンプル ポリシーの各要素に関する要件とオプションについて詳しくは、要素リファレンスをご覧ください。
<VerifyJWT name="JWT-Verify-RS256"> <Algorithm>RS256</Algorithm> <Source>request.formparam.jwt</Source> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <PublicKey> <Value ref="public.publickey"/> </PublicKey> <Subject>apigee-seattle-hatrack-montage</Subject> <Issuer>urn://apigee-edge-JWT-policy-test</Issuer> <Audience>urn://c60511c0-12a2-473c-80fd-42528eb65a6a</Audience> <AdditionalClaims> <Claim name="show">And now for something completely different.</Claim> </AdditionalClaims> </VerifyJWT>
上記のポリシー構成に対し、JWT が以下のヘッダーを含み、
{ "typ" : "JWT", "alg" : "RS256" }
かつ以下のペイロードを含む場合、
{ "sub" : "apigee-seattle-hatrack-montage", "iss" : "urn://apigee-edge-JWT-policy-test", "aud" : "urn://c60511c0-12a2-473c-80fd-42528eb65a6a", "show": "And now for something completely different." }
指定された公開鍵で署名を検証できれば、この JWT は有効とみなされます。
上記と同じヘッダーで以下のペイロードを含む JWT の場合、
{ "sub" : "monty-pythons-flying-circus", "iss" : "urn://apigee-edge-JWT-policy-test", "aud" : "urn://c60511c0-12a2-473c-80fd-42528eb65a6a", "show": "And now for something completely different." }
JWT に含まれる sub クレームが、ポリシー構成で指定された Subject 要素の必須値と一致しないため、署名が検証可能であっても無効と判断されます。
ポリシーは出力をコンテキスト変数に書き込み、後続のポリシーまたは API プロキシの条件でその値を調べられるようにします。このポリシーの変数のリストについては、フロー変数をご覧ください。
鍵要素の設定
JWT の検証に使用する鍵の指定に使用する要素は、次の表に示すように選択したアルゴリズムによって異なります。
アルゴリズム | 鍵要素 | |
---|---|---|
HS* |
<SecretKey> <Value ref="private.secretkey"/> </SecretKey> |
|
RS*、ES*、PS* | <PublicKey> <Value ref="rsa_public_key_or_value"/> </PublicKey> または <PublicKey> <Certificate ref="signed_cert_val_ref"/> </PublicKey> または <PublicKey> <JWKS ref="jwks_val_or_ref"/> </PublicKey> |
|
* 鍵の要件について詳しくは、署名暗号アルゴリズムについてをご覧ください。 |
要素リファレンス
このポリシー リファレンスでは、Verify JWT ポリシーの要素と属性について説明します。
注: 構成は使用する暗号化アルゴリズムにより異なります。特定のユースケースの構成例については、サンプルをご覧ください。
最上位の要素に適用される属性
<VerifyJWT name="JWT" continueOnError="false" enabled="true" async="false">
次の属性は、すべてのポリシーの親要素に共通です。
属性 | 説明 | デフォルト | 要否 |
---|---|---|---|
名前 |
ポリシーの内部名。名前に使用できる文字は、A-Z0-9._\-$ % のみです。ただし、Edge 管理 UI では、英数字以外の文字を自動的に削除するなど、追加の制限が適用されます。必要に応じて、 |
なし | 必須 |
continueOnError |
ポリシーが失敗した場合にエラーを返すには、false に設定します。これはほとんどのポリシーで想定される動作です。ポリシーが失敗した後もフローの実行を続行する場合は、 |
false | 省略可 |
enabled | ポリシーを適用するには true に設定します。ポリシーを「turn off」するには、 |
true | 省略可 |
async | この属性は非推奨となりました。 | false | 非推奨 |
<DisplayName>
<DisplayName>Policy Display Name</DisplayName>
name 属性に加えて、管理 UI プロキシ エディタのポリシーに別の自然言語名でラベルを付けるために使います。
デフォルト | この要素を省略した場合、ポリシーの name 属性の値が使用されます。 |
要否 | 省略可 |
型 | 文字列 |
<Algorithm>
<Algorithm>HS256</Algorithm>
トークンに署名する暗号化アルゴリズムを指定します。RS*、PS*、ES* の各アルゴリズムでは公開鍵 / 秘密鍵ペアを使用し、HS* アルゴリズムでは共有シークレットを使用します。署名暗号化アルゴリズムについてもご覧ください。
複数の値をカンマで区切りながら指定できます。たとえば、「HS256, HS512」や「RS256, PS256」とします。ただし、HS* アルゴリズムとその他のアルゴリズム、または ES* アルゴリズムとその他のアルゴリズムを組み合わることはできません。必要な鍵の種類が異なるからです。RS* アルゴリズムと PS* アルゴリズムは組み合わせることができます。
デフォルト | なし |
要否 | 必須 |
型 | カンマ区切り値の文字列 |
有効な値 | HS256、HS384、HS512、RS256、RS384、RS512、ES256、ES384、ES512、PS256、PS384、PS512 |
<Audience>
<Audience>audience-here</Audience> or: <Audience ref='variable-name-here'/>
このポリシーは、JWT の aud クレームがポリシー構成に指定された値と一致することを確認します。一致しない場合、ポリシーはエラーを返します。このクレームは、この JWT を受け取ると想定された対象を識別します。これは、RFC7519 に記載されている登録済みクレームの 1 つです。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列 |
有効な値 | 対象を識別するフロー変数または文字列 |
<AdditionalClaims/Claim>
<AdditionalClaims> <Claim name='claim1'>explicit-value-of-claim-here</Claim> <Claim name='claim2' ref='variable-name-here'/> <Claim name='claim3' ref='variable-name-here' type='boolean'/> </AdditionalClaims> or: <AdditionalClaims ref='claim_payload'/>
指定された追加クレームが JWT ペイロードに含まれていること、および表明されたクレーム値同士が一致することを検証します。
追加クレームには、標準 JWT クレーム名や登録済み JWT クレーム名以外の名前を使用します。追加クレームの値は、文字列、数値、ブール値、マッピング、または配列です。マッピングとは名前と値のペアのセットのことです。このタイプのクレーム値はポリシー構成で明示的に指定することも、フロー変数への参照を利用して間接的に指定することもできます。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列、数値、ブール値、マッピング |
配列 | (省略可)値が型の配列かどうかを示すには true に設定しますデフォルト: false |
有効な値 | 追加のクレームに使用する任意の値。 |
<Claim>
要素には次の属性があります。
- name -(必須)クレームの名前。
- ref -(省略可)フロー変数の名前。設定された場合、ポリシーはこの変数の値をクレームとして使用します。ref 属性と明示的なクレーム値が両方指定された場合、明示的な値がデフォルトとなり、参照されたフロー変数が解決されない場合に使用されます。
- type -(省略可)文字列(デフォルト)、数値、ブール値、マッピングのいずれか
- array -(省略可)値が型の配列かどうかを示すには true に設定します(デフォルトは false)。
<Claim>
要素を含める場合、クレーム名はポリシーの構成時に静的に設定します。あるいは、JSON オブジェクトを渡してクレーム名を指定することもできます。JSON オブジェクトは変数として渡されるため、クレーム名はランタイムに判定されます。
例:
<AdditionalClaims ref='json_claims'/>
ここで、変数 json_claims
には次の形式の JSON オブジェクトが含まれます。
{ "sub" : "person@example.com", "iss" : "urn://secure-issuer@example.com", "non-registered-claim" : { "This-is-a-thing" : 817, "https://example.com/foobar" : { "p": 42, "q": false } } }
<AdditionalHeaders/Claim>
<AdditionalHeaders> <Claim name='claim1'>explicit-value-of-claim-here</Claim> <Claim name='claim2' ref='variable-name-here'/> <Claim name='claim3' ref='variable-name-here' type='boolean'/> <Claim name='claim4' ref='variable-name' type='string' array='true'/> </AdditionalHeaders>
指定された追加クレームの名前と値のペアが JWT ヘッダーに含まれていること、および表明されたクレーム値同士が一致することを検証します。
追加クレームには、標準 JWT クレーム名や登録済み JWT クレーム名以外の名前を使用します。追加クレームの値は、文字列、数値、ブール値、マッピング、または配列です。マッピングとは名前と値のペアのセットのことです。このタイプのクレーム値はポリシー構成で明示的に指定することも、フロー変数への参照を利用して間接的に指定することもできます。
デフォルト | なし |
要否 | 省略可 |
型 |
文字列(デフォルト)、数値、ブール値、マッピング 明示的に指定しない場合、デフォルトで文字列型になります。 |
配列 | (省略可)値が型の配列かどうかを示すには true に設定しますデフォルト: false |
有効な値 | 追加のクレームに使用する任意の値。 |
<Claim>
要素には次の属性があります。
- name -(必須)クレームの名前。
- ref -(省略可)フロー変数の名前。設定された場合、ポリシーはこの変数の値をクレームとして使用します。ref 属性と明示的なクレーム値が両方指定された場合、明示的な値がデフォルトとなり、参照されたフロー変数が解決されない場合に使用されます。
- type -(省略可)文字列(デフォルト)、数値、ブール値、マッピングのいずれか
- array -(省略可)値が型の配列かどうかを示すには true に設定します(デフォルトは false)。
<CustomClaims>
注: 現在、UI を使用して新しい GenerateJWT ポリシーを追加すると CustomClaims 要素が挿入されます。この要素は機能していないため無視されます。代わりに使用する要素は <AdditionalClaims> です。あとで正しい要素が挿入されるように UI が更新されます。
<Id>
<Id>explicit-jti-value-here</Id> -or- <Id ref='variable-name-here'/> -or- <Id/>
JWT に特定の jti クレームがあることを確認します。text 値と ref 属性が両方とも空白の場合、ポリシーはランダムな UUID を含む jti を生成します。JWT ID(jti)クレームは、JWT の一意の識別子です。jti について詳しくは、RFC7519 をご覧ください。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列または参照 |
有効な値 | 文字列または ID を含むフロー変数の名前 |
<IgnoreCriticalHeaders>
<IgnoreCriticalHeaders>true|false</IgnoreCriticalHeaders>
false に設定すると、JWT の crit ヘッダーにリストされたヘッダーの中に、<KnownHeaders>
要素のリストにないものがあった場合に、ポリシーがエラーを返します。true に設定すると、VerifyJWT ポリシーで crit ヘッダーが無視されます。
この要素を true に設定する状況の 1 つとして、テスト環境で、ヘッダー不足によるエラー発生に対する準備がまだできていない場合があります。
デフォルト | false |
要否 | 省略可 |
型 | Boolean |
有効な値 | true または false |
<IgnoreIssuedAt>
<IgnoreIssuedAt>true|false</IgnoreIssuedAt>
false に設定すると(デフォルト)、未来の時刻を指定する iat
(Issued at)クレームが JWT に含まれていた場合に、ポリシーがエラーを返します。true に設定すると、ポリシーが検証時に iat
を無視します。
デフォルト | false |
要否 | 省略可 |
型 | Boolean |
有効な値 | true または false |
<IgnoreUnresolvedVariables>
<IgnoreUnresolvedVariables>true|false</IgnoreUnresolvedVariables>
false に設定すると、ポリシーで指定された参照値が解決できない場合にエラーを返します。true に設定すると、解決できない変数を空の文字列(null)として扱います。
デフォルト | false |
要否 | 省略可 |
型 | Boolean |
有効な値 | true または false |
<Issuer>
<Issuer ref='variable-name-here'/> <Issuer>issuer-string-here</Issuer>
このポリシーは、JWT の発行者がポリシー構成の要素に指定された文字列と一致することを検証します。JWT の発行者を識別するクレーム。RFC7519 に記載されている登録済みクレームの 1 つです。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列または参照 |
有効な値 | 任意 |
<KnownHeaders>
<KnownHeaders>a,b,c</KnownHeaders> or: <KnownHeaders ref=’variable_containing_headers’/>
GenerateJWT ポリシーは <CriticalHeaders>
要素を使用して、JWT 内の crit ヘッダーに情報を入力します。例:
{ “typ: “...”, “alg” : “...”, “crit” : [ “a”, “b”, “c” ], }
VerifyJWT ポリシーは JWT で crit ヘッダーを調べ、存在する場合は、そこにリストされた各ヘッダーが <KnownHeaders>
要素にもリストされているかどうか確認します。<KnownHeaders>
要素は、crit にリストされた項目のスーパーセットを含むことができます。必要なことは、crit にリストされたすべてのヘッダーが <KnownHeaders>
要素にリストされていることです。ポリシーが crit で検出したヘッダーの中に <KnownHeaders>
にリストされていないものがあると、VerifyJWT ポリシーは失敗します。
<IgnoreCriticalHeaders>
要素を true
に設定することで、VerifyJWT ポリシーが crit ヘッダーを無視するよう構成することもできます。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列のカンマ区切り配列 |
有効な値 | 配列または配列を含む変数の名前 |
<PublicKey/Certificate>
<PublicKey> <Certificate ref="signed_public.cert"/> </PublicKey> -or- <PublicKey> <Certificate> -----BEGIN CERTIFICATE----- cert data -----END CERTIFICATE----- </Certificate> </PublicKey>
JWT 上の署名を検証するために使用される署名済み証明書を指定します。ref 属性を使用して署名済み証明書をフロー変数に渡すか、PEM でエンコードされた証明書を直接指定します。アルゴリズムが RS256 / RS384 / RS512、PS256 / PS384 / PS512、ES256 / ES384 / ES512 のいずれかの場合にのみ使用します。
デフォルト | なし |
要否 | RSA アルゴリズムで署名された JWT を検証するには、証明書、JWKS、Value 要素を使用します。 |
型 | 文字列 |
有効な値 | フロー変数または文字列 |
<PublicKey/JWKS>
<!-- Specify the JWKS. --> <PublicKey> <JWKS>jwks-value-here</JWKS> </PublicKey> or: <!-- Specify a variable containing the JWKS. --> <PublicKey> <JWKS ref="public.jwks"/> </PublicKey> or: <!-- Specify a public URL that returns the JWKS. The URL is static, meaning you cannot set it using a variable. --> <PublicKey> <JWKS uri="jwks-url"/> </PublicKey>
公開鍵のセットを含む JWKS フォーマット(RFC 7517)の値を指定します。アルゴリズムが RS256 / RS384 / RS512、PS256 / PS384 / PS512、ES256 / ES384 / ES512 のいずれかの場合にのみ使用します。
受信 JWT が JWKS のセットに存在する鍵 ID を保持している場合、ポリシーは正しい公開鍵を使用して JWT 署名を検証します。この機能について詳しくは、JSON Web Key Set(JEKS)を使用した JWT の検証をご覧ください。
値を公開 URL から取得した場合、Edge は JWKS を 300 秒間キャッシュに保存します。キャッシュが期限切れになると、Edge は JWKS を再取得します。
デフォルト | なし |
要否 | RSA アルゴリズムを使用して JWT を検証するには、証明書、JWKS、Value 要素を使用します。 |
型 | 文字列 |
有効な値 | フロー変数、文字列値、URL |
<PublicKey/Value>
<PublicKey> <Value ref="public.publickeyorcert"/> </PublicKey> -or- <PublicKey> <Value> -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw2kPrRzcufvUNHvTH/WW Q0UrCw5c0+Y707KX3PpXkZGbtTT4nvU1jC0d1lHV8MfUyRXmpmnNxJHAC2F73IyN C5TBtXMORc+us7A2cTtC4gZV256bT4h3sIEMsDl0Joz9K9MPzVPFxa1i0RgNt06n Xn/Bs2UbbLlKP5Q1HPxewUDEh0gVMqz9wdIGwH1pPxKvd3NltYGfPsUQovlof3l2 ALvO7i5Yrm96kknfFEWf1EjmCCKvz2vjVbBb6mp1ZpYfc9MOTZVpQcXSbzb/BWUo ZmkDb/DRW5onclGzxQITBFP3S6JXd4LNESJcTp705ec1cQ9Wp2Kl+nKrKyv1E5Xx DQIDAQAB -----END PUBLIC KEY----- </Value> </PublicKey>
JWT 上の署名を検証するために使用される公開鍵または公開証明書を指定します。ref 属性を使用して、公開鍵 / 公開証明書をフロー変数に渡すか、PEM でエンコードされた鍵を直接指定します。アルゴリズムが RS256 / RS384 / RS512、PS256 / PS384 / PS512、ES256 / ES384 / ES512 のいずれかの場合にのみ使用します。
デフォルト | なし |
要否 | RSA アルゴリズムで署名された JWT を検証するには、証明書、JWKS、Value 要素を使用します。 |
型 | 文字列 |
有効な値 | フロー変数または文字列 |
<SecretKey/Value>
<SecretKey> <Value ref="private.your-variable-name"/> </SecretKey>
HMAC アルゴリズムでトークンを検証するかトークンに署名するための秘密鍵です。アルゴリズムが HS256、HS384、HS512 のいずれかである場合にのみ使用します。ref 属性を使用して、鍵をフロー変数に渡します。
デフォルト | なし |
要否 | HMAC アルゴリズムでは必須。 |
型 | 文字列 |
有効な値 | 文字列を参照するフロー変数。 注: フロー変数の場合、接頭辞 private が必須になります。例:
|
<Source>
<Source>jwt-variable</Source>
ポリシー構成に含める場合は、検証対象の JWT が存在すると予想されるフロー変数を指定します。
デフォルト | request.header.authorization (デフォルトに関する重要な情報については、上記の注をご覧ください)。 |
要否 | 省略可 |
型 | 文字列 |
有効な値 | Edge のフロー変数名。 |
<Subject>
<Subject>subject-string-here</Subject>
このポリシーは、JWT のサブジェクトの値がポリシー構成で指定された文字列と一致することを確認します。このクレームは、JWT のサブジェクトに関するステートメントを識別または作成します。これは、RFC7519 に記載されている標準的なクレームの 1 つです。
デフォルト | なし |
要否 | 省略可 |
型 | 文字列 |
有効な値 | 主体を一意に識別する任意の値 |
<TimeAllowance>
<TimeAllowance>120s</TimeAllowance>
「猶予期間」を示します。たとえば猶予期間を 60 秒に指定した場合、有効期限切れの JWT でも期限切れの後 60 秒間は有効として扱われます。not-before-time も同様に評価されます。デフォルトは 0 秒(猶予期間なし)です。
デフォルト | 0 秒(猶予期間なし) |
要否 | 省略可 |
型 | 文字列 |
有効な値 |
値、または値を含むフロー変数への参照。期間は次のように指定できます。
|
Flow variables
Upon success, the Verify JWT and Decode JWT policies set context variables according to this pattern:
jwt.{policy_name}.{variable_name}
For example, if the policy name is jwt-parse-token
, then the policy will store
the subject specified in the JWT to this context variable:
jwt.jwt-parse-token.subject
Variable name | Description |
---|---|
claim.audience |
The JWT audience claim. This value may be a string, or an array of strings. |
claim.expiry |
The expiration date/time, expressed in seconds since epoch. |
claim.issuedat |
The Date the token was issued, expressed in seconds since epoch. |
claim.issuer |
The JWT issuer claim. |
claim.notbefore |
If the JWT includes a nbf claim, this variable will contain the value. This is expressed in seconds since epoch. |
claim.subject |
The JWT subject claim. |
claim.name |
The value of the named claim (standard or additional) in the payload. One of these will be set for every claim in the payload. |
decoded.claim.name |
The JSON-parsable value of the named claim (standard or additional) in the payload. One variable is set for
every claim in the payload. While you can also use the claim.name flow variables,
this is the recommended variable to use to access a claim. |
decoded.header.name |
The JSON-parsable value of a header in the payload. One variable is set for
every header in the payload. While you can also use the header.name flow variables,
this is the recommended variable to use to access a header. |
expiry_formatted |
The expiration date/time, formatted as a human-readable string. Example: 2017-09-28T21:30:45.000+0000 |
header.algorithm |
The signing algorithm used on the JWT. For example, RS256, HS384, and so on. See (Algorithm) Header Parameter for more. |
header.kid |
The Key ID, if added when the JWT was generated. See also "Using a JSON Web Key Set (JWKS)" at JWT policies overview to verify a JWT. See (Key ID) Header Parameter for more. |
header.type |
Will be set to JWT . |
header.name |
The value of the named header (standard or additional). One of these will be set for every additional header in the header portion of the JWT. |
header-json |
The header in JSON format. |
is_expired |
true or false |
payload-claim-names |
An array of claims supported by the JWT. |
payload-json |
The payload in JSON format.
|
seconds_remaining |
The number of seconds before the token will expire. If the token is expired, this number will be negative. |
time_remaining_formatted |
The time remaining before the token will expire, formatted as a human-readable string. Example: 00:59:59.926 |
valid |
In the case of VerifyJWT, this variable will be true when the signature is verified, and
the current time is before the token expiry, and after the token notBefore value, if they
are present. Otherwise false.
In the case of DecodeJWT, this variable is not set. |
エラー リファレンス
This section describes the fault codes and error messages that are returned and fault variables that are set by Edge when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.
Runtime errors
These errors can occur when the policy executes.
Fault code | HTTP status | Occurs when |
---|---|---|
steps.jwt.AlgorithmInTokenNotPresentInConfiguration |
401 | Occurs when the verification policy has multiple algorithms. |
steps.jwt.AlgorithmMismatch |
401 | The algorithm specified in the Generate policy did not match the one expected in the Verify policy. The algorithms specified must match. |
steps.jwt.FailedToDecode |
401 | The policy was unable to decode the JWT. The JWT is possibly corrupted. |
steps.jwt.GenerationFailed |
401 | The policy was unable to generate the JWT. |
steps.jwt.InsufficientKeyLength |
401 | For a key less than 32 bytes for the HS256 algorithm, less than 48 bytes for the HS386 algortithm, and less than 64 bytes for the HS512 algorithm. |
steps.jwt.InvalidClaim |
401 | For a missing claim or claim mismatch, or a missing header or header mismatch. |
steps.jwt.InvalidCurve |
401 | The curve specified by the key is not valid for the Elliptic Curve algorithm. |
steps.jwt.InvalidJsonFormat |
401 | Invalid JSON found in the header or payload. |
steps.jwt.InvalidToken |
401 | This error occurs when the JWT signature verification fails. |
steps.jwt.JwtAudienceMismatch |
401 | The audience claim failed on token verification. |
steps.jwt.JwtIssuerMismatch |
401 | The issuer claim failed on token verification. |
steps.jwt.JwtSubjectMismatch |
401 | The subject claim failed on token verification. |
steps.jwt.KeyIdMissing |
401 | The Verify policy uses a JWKS as a source for public keys, but the signed JWT does not
include a kid property in the header. |
steps.jwt.KeyParsingFailed |
401 | The public key could not be parsed from the given key information. |
steps.jwt.NoAlgorithmFoundInHeader |
401 | Occurs when the JWT contains no algorithm header. |
steps.jwt.NoMatchingPublicKey |
401 | The Verify policy uses a JWKS as a source for public keys, but the kid
in the signed JWT is not listed in the JWKS. |
steps.jwt.SigningFailed |
401 | In GenerateJWT, for a key less than the minimum size for the HS384 or HS512 algorithms |
steps.jwt.TokenExpired |
401 | The policy attempts to verify an expired token. |
steps.jwt.TokenNotYetValid |
401 | The token is not yet valid. |
steps.jwt.UnhandledCriticalHeader |
401 | A header found by the Verify JWT policy in the crit header is not
listed in KnownHeaders . |
steps.jwt.UnknownException |
401 | An unknown exception occurred. |
steps.jwt.WrongKeyType |
401 | Wrong type of key specified. For example, if you specify an RSA key for an Elliptic Curve algorithm, or a curve key for an RSA algorithm. |
Deployment errors
These errors can occur when you deploy a proxy containing this policy.
Error name | Cause | Fix |
---|---|---|
InvalidNameForAdditionalClaim |
The deployment will fail if the claim used in the child element <Claim>
of the <AdditionalClaims> element is one of the following registered names:
kid , iss , sub , aud , iat ,
exp , nbf , or jti .
|
build |
InvalidTypeForAdditionalClaim |
If the claim used in the child element <Claim>
of the <AdditionalClaims> element is not of type string , number ,
boolean , or map , the deployment will fail.
|
build |
MissingNameForAdditionalClaim |
If the name of the claim is not specified in the child element <Claim>
of the <AdditionalClaims> element, the deployment will fail.
|
build |
InvalidNameForAdditionalHeader |
This error ccurs when the name of the claim used in the child element <Claim>
of the <AdditionalClaims> element is either alg or typ .
|
build |
InvalidTypeForAdditionalHeader |
If the type of claim used in the child element <Claim>
of the <AdditionalClaims> element is not of type string , number ,
boolean , or map , the deployment will fail.
|
build |
InvalidValueOfArrayAttribute |
This error occurs when the value of the array attribute in the child element <Claim>
of the <AdditionalClaims> element is not set to true or false .
|
build |
InvalidValueForElement |
If the value specified in the <Algorithm> element is not a supported value,
the deployment will fail.
|
build |
MissingConfigurationElement |
This error will occur if the <PrivateKey> element is not used with
RSA family algorithms or the <SecretKey> element is not used with HS Family
algorithms.
|
build |
InvalidKeyConfiguration |
If the child element <Value> is not defined in the <PrivateKey>
or <SecretKey> elements, the deployment will fail.
|
build |
EmptyElementForKeyConfiguration |
If the ref attribute of the child element <Value> of the <PrivateKey>
or <SecretKey> elements is empty or unspecified, the deployment will fail.
|
build |
InvalidConfigurationForVerify |
This error occurs if the <Id> element is defined within the
<SecretKey> element.
|
build |
InvalidEmptyElement |
This error occurs if the <Source> element of the Verify JWT policy
is empty. If present, it must be defined with an Edge flow variable name.
|
build |
InvalidPublicKeyValue |
If the value used in the child element <JWKS> of the <PublicKey> element
does not use a valid format as specified in RFC 7517,
the deployment will fail.
|
build |
InvalidConfigurationForActionAndAlgorithm |
If the <PrivateKey> element is used with HS Family algorithms or
the <SecretKey> element is used with RSA Family algorithms, the
deployment will fail.
|
build |
Fault variables
These variables are set when a runtime error occurs. For more information, see What you need to know about policy errors.
Variables | Where | Example |
---|---|---|
fault.name="fault_name" |
fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. | fault.name Matches "TokenExpired" |
JWT.failed |
All JWT policies set the same variable in the case of a failure. | JWT.failed = true |
Example error response
For error handling, the best practice is to trap the errorcode
part of the error
response. Do not rely on the text in the faultstring
, because it could change.
Example fault rule
<FaultRules> <FaultRule name="JWT Policy Errors"> <Step> <Name>JavaScript-1</Name> <Condition>(fault.name Matches "TokenExpired")</Condition> </Step> <Condition>JWT.failed=true</Condition> </FaultRule> </FaultRules>