JWT/Claim Injection in an Endpoint with Basic and JWT Mechanisms #26679
-
I have the following endpoint for which both Basic and JWT auth is enabled: @RequestScoped
public class FooResource {
@Inject JsonWebToken jwt;
@Inject
@Claim(standard = Claims.sub)
String tokenSubject;
// ...
} This currently would not work because
Is this the expected behavior? I was expecting to see a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
/cc @manovotn, @mkouba, @sberyozkin |
Beta Was this translation helpful? Give feedback.
-
@Akaame I think this error is correct, You should probably inject only |
Beta Was this translation helpful? Give feedback.
@Akaame I think this error is correct,
null
for an individual claim can also mean a token is available but the claim is not.You should probably inject only
SecurityIdentity
and then cast the principal toJsonWebToken
ifsecurityIdentity.getPrincipal()
is an instance ofJsonWebToken
and then get claims directly fromJsonWebToken
; this should work better when more than authentication mechanism is used