feat: added get userdata from jwt helper#24
Merged
LucaSchmitz2003 merged 1 commit intomainfrom Oct 20, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a backend helper class to extract user information from JWTs and a comprehensive test suite validating its behavior.
- Introduces UserInformationJWT with static accessors for common claims, roles aggregation, and authentication checks
- Adds unit tests that construct a representative Jwt and verify claim getters, role aggregation, case-insensitive role checks, and unauthenticated scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/com/ase/userservice/security/UserInformationJWT.java | New helper class implementing claim getters, role aggregation, and auth checks |
| src/test/java/com/ase/userservice/security/UserInformationJWTTest.java | New tests covering claim access, roles, case-insensitive checks, and unauthenticated cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
LucaSchmitz2003
approved these changes
Oct 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UserInformationJWT - Helper Class
The backend provides a convenient helper class
UserInformationJWTto extract user information from JWT tokens, similar to the frontend'suseUserhook.Example
Available Methods
getUserId()- Get user ID (subject)getUsername()- Get username (preferred_username)getEmail()- Get email addressgetFirstName()- Get first namegetLastName()- Get last namegetRoles()- Get all roles (from groups, realm_access, resource_access)hasRole(String role)- Check if user has specific role (case-insensitive)getClaim(String name)- Get custom JWT claimisAuthenticated()- Check if user is authenticated