aws / aws/bedrock-agentcore-sdk-python
Support for Auth0 credential provider when using the `request_access_token` decorator and for `Identity.get_token`
- Vorherrschende Sprache
- Python
- Sterne
- 761
- Forks
- 147
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 7
Beschreibung
**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:
```
Beitragsleitfaden
Rechercherichtung
Beginne damit, den Decorator requires_access_token und die Einstiegspunkte Identity.get_token zu finden, und verfolge anschließend, wie ihre Anforderungsparameter für den Credential-Provider zusammengestellt werden. Die in der Issue vorgeschlagene Signatur identifiziert custom_parameters als die benötigte Eingabe; als erledigt gilt die Aufgabe, wenn Auth0-Audience-Parameter beide Abläufe erreichen können und das zurückgegebene Token akzeptiert wird, ohne boto3 direkt zu verwenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, python
- Bereich
- authentication, backend
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100