Skip to content

Align JwtAuthFilter parsing across microservices and amber, deduplicate JwtConsumer #4895

Closed

Description

@Yicong-Huang

Task Summary

Two JWT parsing paths currently produce different SessionUser objects from the same token:

  • org.apache.texera.auth.JwtParser (used by JwtAuthFilter in 4 microservices and a couple of resource-level callers in amber) reads 5 claims (subject, email, userId, googleId, role) and drops googleAvatar even though JwtAuth.jwtClaims writes it into every issued token.
  • org.apache.texera.web.auth.UserAuthenticator (used by amber's toastshaman-based filter) reads the same 5 + reads comment and accountCreation claims that the issuer never writes, so they are always null in practice. It also drops googleAvatar.

There are also two JwtConsumer instances (JwtParser's private one and JwtAuth.jwtConsumer) built with byte-identical builder chains. They share the same secret and the same clock-skew/exp/sub config — pure duplication.

Refactor:

  1. Extract a single JwtParser.claimsToSessionUser(JwtClaims): SessionUser that reads all 6 issued claims (including googleAvatar).
  2. Make JwtParser.parseToken use JwtAuth.jwtConsumer instead of building its own. Delete the internal copy.
  3. Rewrite UserAuthenticator.authenticate(JwtContext) to a one-liner that delegates to JwtParser.claimsToSessionUser(context.getJwtClaims). Drop the dead comment / accountCreation reads.

Task Type

  • Refactor / Cleanup

Activity

  1. added theissue type on May 4, 2026
  2. Yicong-Huang commented on May 4, 2026

    @Yicong-Huang
    ContributorAuthor

    /take

  3. added a commit that references this issue on May 4, 2026
    6b4d7c4
  4. added a commit that references this issue on May 4, 2026
    786a920
  5. added a commit that references this issue on Jun 22, 2026
    56e761a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions