feat: Jwt -- don't force "upn" claim #9307
Closed
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.
Description
Fixes #5151
Adjusts the
Jwtclass so thatuserPrincipal()returns the value of aupn,preferred_username, orsubclaim in that order of preference; but the class does not automatically insert aupnclaim whenever apreferred_usernameorsubis present. This meansuserPrincipal()returns a value to satisfy the Eclipse MicroProfile Interoperable JWT RBAC. But theJwtclass is still usable for use-cases beyond that very specific profile where aupnclaims in not required, not desired, and may even be forbidden.A
upnclaim can still be set.Unit tests are added to confirm that
Jwt.userPrincipal()falls back tosubifupnis absent; and to confirm thatupnis no longer automatically (and unexpectedly) added just becausesubis set.All the existing unit tests still pass.
Documentation
The javadoc for
Jwt.userPrincipal()andJwt.Builder.userPrincipal(String)is adjusted.