Skip to content

Fix regenerateAccessKey putting the wrong subject in the JWT - #3708

Merged
hmiguim merged 1 commit into
developmentfrom
fix/regenerate-access-key-wrong-jwt-subject
Jul 30, 2026
Merged

Fix regenerateAccessKey putting the wrong subject in the JWT#3708
hmiguim merged 1 commit into
developmentfrom
fix/regenerate-access-key-wrong-jwt-subject

Conversation

@luis100

@luis100 luis100 commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • accessKey.getName() is the access key's human-readable label (e.g. "mcp"), not the RODA username - that's accessKey.getUserName(). createAccessKey correctly uses the username; regenerateAccessKey built the JWT inline and used the wrong field.
  • The bug is silent and severe: JwtUtils.generateToken signs a token whose subject doesn't correspond to any real user. RODA's own /authenticated endpoint doesn't reject this - it decodes the token, fails to find a matching user, and returns a degenerate User shell (id=null, name=null, uuid="user-null", guest=false, allRoles=[]) with 200 OK instead of erroring. Every downstream role check then silently sees a "real" but permission-less user rather than a clear authentication failure.
  • Any AccessKey regenerated via RODA's UI (the Access Token tab's "regenerate" action, not "create") was affected - only brand-new keys worked correctly.

Test plan

  • Compiles cleanly
  • Verified live: created an AccessKey, regenerated it via POST /api/v2/members/users/access-keys/regenerate/{id}, decoded the resulting JWT (sub now correctly the username, not the key's label), and confirmed GET /api/v2/members/users/authenticated with that token returns the full identity and role list.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

accessKey.getName() is the access key's human-readable label (e.g.
"mcp"), not the RODA username - that's accessKey.getUserName().
createAccessKey correctly uses the username (via
accessKey.setUserName(id), consumed by the model service layer when it
generates the token); regenerateAccessKey built the JWT inline and used
the wrong field.

The bug is silent and severe: JwtUtils.generateToken signs a token
whose subject doesn't correspond to any real user. RODA's own
/authenticated endpoint doesn't reject this - it decodes the token,
fails to find a matching user, and returns a degenerate User shell
(id=null, name=null, uuid="user-null", guest=false, allRoles=[]) with
200 OK instead of erroring. Every tool/role check downstream then
silently sees a "real" but permission-less user rather than a clear
authentication failure. Any AccessKey regenerated via RODA's UI (the
Access Token tab's "regenerate" action, not "create") was affected -
only brand-new keys worked correctly.

Verified live: created an AccessKey, regenerated it via
POST /api/v2/members/users/access-keys/regenerate/{id}, decoded the
resulting JWT (sub now correctly "admin", not the key's label), and
confirmed GET /api/v2/members/users/authenticated with that token
returns the full admin identity and role list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01263fsB7QYevDFgwAY8okcq
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug labels Jul 29, 2026
@luis100
luis100 requested a review from hmiguim July 29, 2026 12:22
@luis100 luis100 assigned luis100 and hmiguim and unassigned luis100 Jul 29, 2026
@hmiguim
hmiguim merged commit 60351c2 into development Jul 30, 2026
5 checks passed
@hmiguim
hmiguim deleted the fix/regenerate-access-key-wrong-jwt-subject branch July 30, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants