Skip to content
Advertisement

Quarkus JWT Returning Unauthorized on deployment

I have a Quarkus project that expose some REST Endpoints. When working on dev mode or running from the local build docker container all work fine, those endpoints annotated with @RolesAllowed and @PermitAll work as supposed to be. But when I deploy to a AWS service with the following steps:

  1. Commit to Gitlab
  2. Run Gitlab CICD
  3. Send result with the config to an AWS S3 Bucket
  4. Trigger AWS codepipeline
  5. Deploy to Elastic Bean using docker image

After that the container is deployed all endpoints with @PermitAll work fine but those with @RolesAllowed responds with 401 Unauthorized, the token sent to those endpoints is valid, it is correctly formed and has not expired.

JavaScript

The project is running on Quarkus Platform 2.2.3.Final on JDK 11 and I’m using the following extensions

Installed features: [agroal, cdi, config-yaml, hibernate-orm, hibernate-orm-panache, hibernate-validator, jaeger, jdbc-h2, jdbc-mysql, mailer, narayana-jta, qute, rest-client, rest-client-jackson, resteasy, resteasy-jackson, security, smallrye-context-propagation, smallrye-health, smallrye-jwt, smallrye-openapi, smallrye-opentracing, swagger-ui, vertx, vertx-web]

UPDATE:

I dive into the Quarkus documentation and added a few configurations and map all authorization exceptions and get the log and stacktrace, But I don’t know why is happening as I’m using the procedure that que guide says when create the public and private key. And also if I put all the base64 token in the jwt.io debugger and I paste the public key content it says that the signature is valid.

JavaScript

Advertisement

Answer

The problem was the AWS time zone configuration, for some strange reason it interfered with how Quarkus validates the IAT and EXP claims of the token. I removed the AWS time zone settings and set the zone using a system property at the JVM level and the problem was completely fixed.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement