hasura / hasura/graphql-engine

Error: Could not verify JWT: JWSError JWSInvalidSignature Hasura, Docker and Cognito

Open
#3,919 16 comments 4 reactions 0 assignees View on GitHub
a/authz k/question support/needs-more-info
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

I'm developing an application in which I use AWS Cognito as authentication provider.
The Hasura Engine is configured in a docker-compose file and it runs in a AWS EC2 machine.

Following this tutorial https://hasura.io/blog/hasura-authentication-explained/#cognito I set HASURA_GRAPHQL_JWT_SECRET as shows below:

```
HASURA_GRAPHQL_JWT_SECRET: '{"type":"RS256","jwk_url":"https://cognito-idp..amazonaws.com//.well-known/jwks.json","claims_format":"stringified_json"}'
```

From the client, I get jwtToken from idToken and put it in authorization header:

```
{
Authorization: 'Bearer '
}
```

Then follows the error:

```
nhandled Rejection (Error): Could not verify JWT: JWSError JWSInvalidSignature: {"response":{"errors":[{"extensions":{"path":"$","code":"invalid-jwt"},"message":"Could not verify JWT: JWSError JWSInvalidSignature"}],"status":200}
```

I don't know if there is any error in my stringified jwks, is it the problem?

As told by @praveenweb in https://github.com/hasura/graphql-engine/issues/3513 I was careful about putting HASURA_GRAPHQL_JWT_SECRET value in a single quote.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the docker-compose configuration and the HASURA_GRAPHQL_JWT_SECRET value, then compare it with the AWS Cognito token described in the issue. Done means identifying whether the JWT configuration and Authorization header are accepted by Hasura without the JWSInvalidSignature error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, graphql
Domain
api, authentication, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.