How to @Inject JsonWebToken when having both quarkus-smallrye-jwt and quarkus-oidc in Quarkus application #33976
-
In my Quarkus application, there are two types of authentication:
For the controllers are marked
For normal controllers used local JWT then
So, do we have any ways to configure this one? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
/cc @Ladicek (smallrye), @jmartisk (smallrye), @pedroigor (oidc), @phillip-kruger (smallrye), @radcortez (smallrye), @sberyozkin (jwt,oidc) |
Beta Was this translation helpful? Give feedback.
-
Can you try configuring a path based authentication:
I'm not sure though it will fix the ambiguity with I think the best solution should be to have |
Beta Was this translation helpful? Give feedback.
-
Thank for your help @sberyozkin. But it's still conflicted for the providers.
=> So, this provider will be used for OIDC controllers as well since I saw that local JWT and OIDC used the same => So, this provider will be used for normal controllers as well |
Beta Was this translation helpful? Give feedback.
-
@trunghoangminh Have you applied a path-based boundary ? That should help, can I have a look at the current controller code (just the one related to the injection) and |
Beta Was this translation helpful? Give feedback.
-
@sberyozkin
I already moved These are all about JWT configs and OIDC configs.
For path-based boundary, I already though about this one. But the smallrye-jwt and OIDC token are "Bearer". So, do we have any ways to config them? |
Beta Was this translation helpful? Give feedback.
-
@trunghoangminh 2.7.3.Final is the very old version, please try to update to the newer one if you can. Right, the problem is, you are trying to combine 2 conflicting mechanisms, So if smallrye-jwt creates an authentication request then the OIDC identity provider will ignore it and the one provided by smallrye-jwt will be tried Give it a try please |
Beta Was this translation helpful? Give feedback.
-
Thank for your help @sberyozkin |
Beta Was this translation helpful? Give feedback.
@trunghoangminh
Can you try configuring a path based authentication:
https://quarkus.io/guides/security-authentication-mechanisms-concept#path-specific-authentication-mechanisms
bearer
mechanism provided bysmallrye-jwt
would cover the local authentication paths,code
(it is not mentioned in those docs though) provided byquarkus-oidc
would cover the path requiring Keycloak authentication.I'm not sure though it will fix the ambiguity with
JsonWebToken
producers, bothquarkus-smallrye-jwt
andquarkus-oidc
provide bearer token authentication and support this injection without@IdToken
qualifier.I think the best solution should be to have
SecurityIdentity
injected instead for the local aut…