Skip to content

Gateway OAuth2: missing id detail from token attributes from api /api/account #29580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 5 tasks
ldaloia-dev opened this issue May 23, 2025 · 0 comments
Open
1 of 5 tasks

Comments

@ldaloia-dev
Copy link

Overview of the issue

With oauth2 authentication, id attribute is not filled in /api/account

Motivation for or Use Case

The attribute can be used for business logic.

In older jhipster version (ex. 7.8.1), there is following logic

// handle resource server JWT, where sub claim is email and uid is ID
if (details.get("uid") != null) {
    user.setId((String) details.get("uid"));
    user.setLogin(sub);
} else {
    user.setId(sub);
}
Reproduce the error

Login or call /api/account endpoint

Related issues
Suggest a Fix
SecurityUtils.extractDetailsFromTokenAttributes

After this line

Optional.ofNullable(attributes.get("uid")).ifPresent(id -> details.put("id", id));

add optional put

Optional.ofNullable(attributes.get("sub")).ifPresent(id -> details.putIfAbsent("id", id));
JHipster Version(s)

8.11.0

Browsers and Operating System
  • Tickets opened without reproduction steps or that doesn't follows the template recommendation will be closed.
  • This issue is prompt-related or an error that prevents JHipster from generating an application.
  • I don't have a JDL otherwise I should open an JDL Issue
  • The application is not successfully generated otherwise, I should open an Issue with jhipster info
  • Checking this box is mandatory (this is just to show you read everything)
@ldaloia-dev ldaloia-dev changed the title Gateway oauth2: missing id detail from token attributes from api /api/account Gateway OAuth2: missing id detail from token attributes from api /api/account May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant