- Newest
- Most votes
- Most comments
It sounds like you're experiencing an issue where your JWT authorizer is not being applied as expected to your HTTP API Gateway route. There are a few things you can check to debug this issue:
-
Verify the authorizer configuration: Make sure the JWT authorizer is correctly configured with the proper issuer, audience, and identity source. Double-check that the audience in your configuration matches the intended audience for your JWT tokens.
-
Check the deployment: Although you mentioned that the stage is set to autodeploy, it's worth confirming that the changes have been properly deployed. Try manually deploying the API to ensure the latest configuration is active.
-
Examine the request: When sending requests through Postman, ensure you're targeting the correct API endpoint and stage. Sometimes, the issue can be that you're hitting a different version of the API or a route that doesn't have the authorizer applied.
-
Validate the JWT token: Even though your Postman is not configured to send the JWT, try sending a request with a valid JWT token in the Authorization header. This can help determine if the issue is with the authorizer configuration or the lack of a token.
-
Check API Gateway logs: Enable logging for your API and check the CloudWatch logs. This can provide insights into whether the authorizer is being triggered and if there are any errors during the authorization process.
-
Use the API Gateway console: The API Gateway console has built-in tools for testing your routes. Try using these to test your endpoint with and without a valid JWT to see if the behavior differs from Postman.
-
Decode and verify JWT: Use a tool like jwt.io to decode your JWT and verify that it matches the issuer, audience, and scopes that your API requires. This can help identify any mismatches in the token claims.
-
Check for caching issues: API Gateway caches the public key used for JWT validation for up to two hours. If you've recently updated your JWT configuration, you might need to wait for the cache to clear or force a redeployment.
If none of these steps resolve the issue, you may want to review the full configuration of your API, including any other authorizers or security measures that might be interfering with the JWT authorizer. Additionally, ensure that your JWT authorizer is correctly attached to the specific route you're testing, as it's possible to have different authorization settings for different routes within the same API.
Remember, for API Gateway to authorize a request, the JWT's aud or client_id claim must match one of the audience entries configured for the authorizer. If both are present, API Gateway evaluates the aud claim.
If you continue to experience issues, you may need to contact AWS support for further assistance in troubleshooting your specific API Gateway configuration.
Sources
Troubleshooting issues with HTTP API JWT authorizers - Amazon API Gateway
Control access to HTTP APIs with JWT authorizers in API Gateway - Amazon API Gateway
Create and troubleshoot Cognito and API Gateway integrations | AWS re:Post
Configure an API Gateway Lambda authorizer - Amazon API Gateway
Relevant content
asked 5 years ago

The thing is, it should be more difficult to get an unauthorized request through rather than vice versa. It's like this route is using my old authorizer, not the newly configured one. It accepts traffic without the Authorization header.