Update a JWT authorizer
You update a JWT authorizer by replacing its whole configuration. API Gateway accepts a single
replace operation on the /jwtConfiguration path, with the
complete configuration as the value. API Gateway keeps nothing from the previous configuration, so
any issuer or claim rule that you leave out is removed. API Gateway runs OIDC discovery again for
every issuer on each update.
To change one part of the configuration, read the current configuration, edit it, and send it back. The following steps change an authorizer by using the AWS CLI.
To update a JWT authorizer using the AWS CLI
-
Read the current configuration with the get-authorizer command and save the
jwtConfigurationobject to a file namedjwt-config.json. -
Edit the file. For example, to add a second issuer, append it to the
issuerslist. Keep the issuers that you still trust, because API Gateway removes any issuer that is not in the file. RemovejwksUrifrom each issuer. -
Send the whole file back as the value of a
replaceoperation on the/jwtConfigurationpath.aws apigateway update-authorizer \ --rest-api-idapi-id\ --authorizer-idauthorizer-id\ --patch-operations "$(jq -n --rawfile v jwt-config.json \ '[{op:"replace",path:"/jwtConfiguration",value:$v}]')"
This pattern supports an identity provider migration. To migrate, add the new issuer alongside the old one and let clients move over. When all clients use the new issuer, remove the old issuer and update the authorizer again.
The get-authorizer response includes a resolved jwksUri for
each issuer. Remove jwksUri from each issuer before you send the configuration
back in a replace operation. API Gateway resolves jwksUri through OIDC
discovery. If you include it, API Gateway rejects the request with a 400
error.
Update a JWT authorizer using the console
The following steps show how to update a JWT authorizer by using the console. When you save, the console replaces the authorizer's configuration, so keep the issuers and claim rules that you still need.
To update a JWT authorizer using the console
Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway
. -
Choose a REST API.
-
In the main navigation pane, choose Authorizers.
-
Select the JWT authorizer that you want to update, and then choose Edit.
-
(Optional) For Authorizer name, enter a new name.
-
(Optional) For Identity source, enter the request header that carries the token.
-
(Optional) For Allowed signing algorithms, add or remove algorithms. You must keep at least one algorithm.
-
Under Issuers, update the identity providers that issue tokens for this API:
-
To change an issuer, edit its Issuer URL or Audiences.
-
To change an issuer's claim rules, expand Additional claims - optional, and then choose Edit additional claims. If the issuer has no claim rules, choose Add additional claims. Add, change, or remove claim rules, and then choose Save.
-
To add an issuer, choose Add issuer, and then enter its details. You can add up to 10 issuers.
-
To remove an issuer, choose Remove issuer for that issuer.
-
-
Choose Save changes.
Convert an existing authorizer to a JWT authorizer
You can't change an authorizer's type in the console. To convert an authorizer, use the AWS CLI or the API.
You can convert a TOKEN authorizer or an Amazon Cognito user pool authorizer to a
JWT authorizer. Send a replace operation on the /type path to
set the type to JWT, together with a replace operation on the
/jwtConfiguration path that supplies the new configuration, in one
request.
When you convert an authorizer to a JWT authorizer, remove the
authorizerUri, authorizerCredentials,
providerARNs, identityValidationExpression, and
authorizerResultTtlInSeconds fields. For a field that doesn't support
a remove operation, use a replace operation with an empty
value. API Gateway returns a 400 error if any of these fields has a
value.
After you convert the authorizer, change the authorization type to JWT
on each method that uses it, and then deploy the API. For more information, see Attach a JWT authorizer to methods and require scopes.
Changes to an authorizer take effect only after you deploy the API. After you update an authorizer, deploy the API to a stage. For more information, see Deploy REST APIs in API Gateway.