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