aws / aws/bedrock-agentcore-sdk-python

Support for Auth0 credential provider when using the `request_access_token` decorator and for `Identity.get_token`

オープン
#109 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
761
フォーク
147
平均マージ
1日 23時間
マージ済み PR(30日)
7

説明

**Is your feature request related to a problem? Please describe.**
In order to get an access_token from Auth0, you need to pass an additional `audience` parameter in the request.
Using boto3 directly this can be accomplished with:

```
workload_access_token=BedrockAgentCoreContext.get_workload_access_token()
resp = acr.get_resource_oauth2_token(
workloadIdentityToken=workload_access_token, resourceCredentialProviderName='resource-provider-oauth-gateway',
scopes=[],
customParameters={'audience': ''},
oauth2Flow='M2M')
print(resp['access_token'])
```

The `request_access_token` decorator does not support passing that parameter and the request fails since the returned token is an opaque token and not a valid JWT.

```
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the GetResourceOauth2Token operation: Error parsing ClientCredentials response
```

**Describe the solution you'd like**
Add a `customParameters` parameter to the decorator

**Describe alternatives you've considered**
One can use the boto3 API directly, but introduces friction to the developer experience

**Additional context**
The new signature should be:
```
def requires_access_token(
*,
provider_name: str,
into: str = "access_token",
scopes: List[str],
on_auth_url: Optional[Callable[[str], Any]] = None,
auth_flow: Literal["M2M", "USER_FEDERATION"],
callback_url: Optional[str] = None,
custom_parameters: Optional[dict] = None,
force_authentication: bool = False,
token_poller: Optional[TokenPoller] = None,
) -> Callable:
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず requires_access_token デコレーターと Identity.get_token エントリーポイントを見つけ、次にそれらの credential-provider リクエストパラメーターがどのように組み立てられるかを追跡します。issue で提案されているシグネチャは custom_parameters を必要な入力として特定しています。完了の条件は、Auth0 の audience パラメーターが両方のフローに到達し、返されたトークンが boto3 を直接使わずに受け入れられることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, python
領域
authentication, backend
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。