翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
OIDC プロバイダーのクライアントとオーディエンスの検証
ID ソースをポリシーストアに追加すると、Verified Permissions には、ID トークンとアクセストークンが意図したとおりに使用されていることを確認する設定オプションがあります。この検証は、 IsAuthorizedWithToken
および BatchIsAuthorizedWithToken
API リクエストの処理で行われます。この動作は、ID トークンとアクセストークン、および Amazon Cognito と OIDC ID ソースによって異なります。Amazon Cognito ユーザープールプロバイダーを使用すると、Verified Permissions は ID トークンとアクセストークンの両方でクライアント ID を検証できます。OIDC プロバイダーを使用すると、Verified Permissions は ID トークンのクライアント ID とアクセストークンの対象者を検証できます。
クライアント ID は、アプリケーションが使用する ID プロバイダーインスタンスに関連付けられた識別子です1example23456789
。例: 。対象者は、 など、アクセストークンの目的の証明書利用者または送信先に関連付けられた URL パスですhttps://mytoken.example.com
。アクセストークンを使用する場合、aud
クレームは常に対象者に関連付けられます。
OIDC ID トークンには、 などのクライアント IDs を含むaud
クレームがあります1example23456789
。
OIDC Access トークンには、 などのトークンのオーディエンス URL を含むaud
クレームとhttps://myapplication.example.com
、 などのクライアント IDs を含むclient_id
クレームがあります1example23456789
。
ポリシーストアを設定するときは、ポリシーストアがトークンの対象者を検証するために使用する対象者検証の値を 1 つ以上入力します。
-
ID トークン – Verified Permissions は、
aud
クレーム内のクライアント ID の少なくとも 1 つのメンバーが対象者検証値と一致することを確認して、クライアント IDs を検証します。 -
アクセストークン – Verified Permissions は、
aud
クレームの URL が対象者検証値と一致することを確認して対象者を検証します。aud
クレームが存在しない場合、対象者はcid
またはclient_id
クレームを使用して検証できます。ID プロバイダーに正しい対象者のクレームと形式を確認してください。
JWTs のクライアント側の認可
アプリケーションで JSON ウェブトークンを処理し、ポリシーストア ID ソースを使用せずにそのクレームを Verified Permissions に渡すことができます。JSON ウェブトークン (JWT) からエンティティ属性を抽出し、Verified Permissions に解析できます。
この例では、JWT.1 を使用してアプリケーションから Verified Permissions を呼び出す方法を示します。
async function authorizeUsingJwtToken(jwtToken) { const payload = await verifier.verify(jwtToken); let principalEntity = { entityType: "PhotoFlash::User", // the application needs to fill in the relevant user type entityId: payload["sub"], // the application need to use the claim that represents the user-id }; let resourceEntity = { entityType: "PhotoFlash::Photo", //the application needs to fill in the relevant resource type entityId: "jane_photo_123.jpg", // the application needs to fill in the relevant resource id }; let action = { actionType: "PhotoFlash::Action", //the application needs to fill in the relevant action id actionId: "GetPhoto", //the application needs to fill in the relevant action type }; let entities = { entityList: [], }; entities.entityList.push(...getUserEntitiesFromToken(payload)); let policyStoreId = "PSEXAMPLEabcdefg111111"; // set your own policy store id const authResult = await client .isAuthorized({ policyStoreId: policyStoreId, principal: principalEntity, resource: resourceEntity, action: action, entities, }) .promise(); return authResult; } function getUserEntitiesFromToken(payload) { let attributes = {}; let claimsNotPassedInEntities = ['aud', 'sub', 'exp', 'jti', 'iss']; Object.entries(payload).forEach(([key, value]) => { if (claimsNotPassedInEntities.includes(key)) { return; } if (Array.isArray(value)) { var attibuteItem = []; value.forEach((item) => { attibuteItem.push({ string: item, }); }); attributes[key] = { set: attibuteItem, }; } else if (typeof value === 'string') { attributes[key] = { string: value, } } else if (typeof value === 'bigint' || typeof value ==='number') { attributes[key] = { long: value, } } else if (typeof value === 'boolean') { attributes[key] = { boolean: value, } } }); let entityItem = { attributes: attributes, identifier: { entityType: "PhotoFlash::User", entityId: payload["sub"], // the application needs to use the claim that represents the user-id } }; return [entityItem]; }
¹ このコード例では、aws-jwt-verify