I am experimenting with the AWS Api Gateway's beta "HTTP API" functionality.
As part of this experimentation I am trying to authorize access to the api using a "JWT Authorizer":
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html
The documentation states that the JWT will go through a workflow consisting of a series of checks/verification on the JWT before it is authorized, or rejected.
Without the authorizer, the endpoint is accessible. With the authorizer I get a 401 response with the json:
{"message":"Unauthorized"}
I am trying work out at which step the Authorizer is rejecting the JWT. I have setup a log for the api endpoint and see the request coming in, but it provides no insights into why the authorization is failing.
Is there a way to debug why/where the authorizer is failing?
Note: This is not talking about lamda authorizers, and I am not using Cognito to generate the JWT.
401 means that the authentication of the user could not be established. Basically, the JWT is either faulty or is not being provided with the request in the header that API Gateway is expecting.
Also, API Gateway is not a full blown server, so won't get to debug how API gateway is making use of the JWT. While that maybe a bummer, please do note that it does provide you a highly scalable, reliable and cheap HTTP endpoint for your backend with a built in JWT based authentication support and it just became available across most of the regions. So, I wouldn't cross it out just yet.
Coming back to your question. Though I don't know how to help with the debug part. I can tell you the steps I took to experiment with the JWT authorizer without writing a single line of code.
After doing all of this, I was able to test out that API gateway was able to work with the JWT that I generated. Now, I can go about coding this thing with more confidence and luckily, there are tools in JAVA, node, etc, already available.
Take a look at the response. There is a header called www-authenticate, which contains an error response, if authentication failed.
i.e:
www-authenticate: Bearer scope="" error="invalid_token" error_description="JWKS communication error"
If you use curl, you can try it with -v to see the full response including the header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With