Replies: 14 comments 3 replies
-
/cc @pedroigor (oidc), @sberyozkin (oidc) |
Beta Was this translation helpful? Give feedback.
-
@ayhanap If you use Have you considered using |
Beta Was this translation helpful? Give feedback.
-
@ayhanap This test shows how to use the RT directly if you prefer to avoid
In general, |
Beta Was this translation helpful? Give feedback.
-
OK. So your endpoint is protected by the custom JWT mechanism, and after the token is verified, you'd like to propagate it to the external service, right ? In that case I'm not sure why you would like to use OidClient to support the authorization code flow grant. If you have to propagate the existing token, then It sounds like Token Propagation is what you are after: https://quarkus.io/guides/security-openid-connect-client-reference#token-propagation-reactive with this feature you just Does it help ? |
Beta Was this translation helpful? Give feedback.
-
@ayhanap I see. Something like that should do |
Beta Was this translation helpful? Give feedback.
-
Yes as far as I see it can refresh without second client. I was mostly
trying to see options without extending anything but that seems not
possible. I will try to write a custom filter as I explained above tonight
and see how it goes.
As for the use case, I found it surprising this looks like an edge case,
because this is what you need to do if you call a 3rd party api with
oauth2.
Actually the real edge use case is the next step after I achieve this, I
need to dynamically use same 3rd party api for different users/customers,
each having seperate code/tokens etc. Didn’t mention this to complicate
things.
…On 22 Jul 2023 Sat at 23:29 Sergey Beryozkin ***@***.***> wrote:
Or may be you don't need the 2nd RT client at all, or even use OidcCient
directly, since OidcClient injected in the filter will refresh the token
itself - if the current access token has expired or nearly expired (set the
refresh token skew) - the RT will be used to get a new pair of AT and RT.
Sorry, I have to admit I'm not quite following the use case, please
experiment more and let me know how it goes
—
Reply to this email directly, view it on GitHub
<#34932 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJR7V32WAAC4XBXDOU33JTXRQZ2LANCNFSM6AAAAAA2T24TYE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I feel may be we are misunderstanding each other a bit, but sometimes it can take awhile to get shared understanding. In your case - you have an endpoint attempting to manage the communication with OAuth2 server using an authorization code flow, which is not related to the authentication of this actual endpoint - I have to admit it does not make sense to me - but I know - this is because I'm missing something in what you are trying to achieve. If one does the authorization code flow - it means the users are being authenticated into the current endpoint - but this is not the right grant type to use if the endpoint needs to acquire the token and use to access something downstream without the users being redirected to authenticate etc. It is client credentials or password grants or other grants involving no user interaction have to be used. If we look at your config:
It already looks wrong to me, sorry I did not pay attention earlier. May be this is where the confusion is coming from - looks like you should use another grant type. Thanks |
Beta Was this translation helpful? Give feedback.
-
@ayhanap FYI, see https://quarkus.io/guides/security-openid-connect-client-reference#other-grants about the use of the https://github.com/quarkusio/quarkus/blob/main/integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/UnprotectedResource.java#L62 This imitates an endpoint managing the code flow itself - if for some reasons,
Hope it clarifies it. I believe you need to use a different grant type. |
Beta Was this translation helpful? Give feedback.
-
@sberyozkin First of all thanks for trying to understand my problem. My config had I will try to explain the flow again.
I think at point 7 I need to initialize OidcClient with refresh_token grant. Which works mostly but only allows for me to get new pair of AT/RT with existing RT. (This would lead basically to throw away AT everytime I call my service) I will also try to create a custom filter to use previous AT until it fails (or check its exp time) then use new refresh_token grant OidcClient. My confusion was mostly around that point 7 that at first I tought to reuse code grant which now is clear should be a refresh_token grant. I will finish coding today and see, but everything looks ok. |
Beta Was this translation helpful? Give feedback.
-
@ayhanap I see, thanks, yeah, at point 7 - since the original OIDC client is about the dynamic code exchange, you likely need to have another one using the RT only (see the links above), but you can support this RT grant client with injected |
Beta Was this translation helpful? Give feedback.
-
@ayhanap sorry, just one more idea to explore, path based authentication, for paths requiring the user permissions one enables oidc. Might not work if at this point user must already be authenticated, but otherwise will replace manual oidc client based code flow management as quarkus oidc will handle everything itself, incl the session management |
Beta Was this translation helpful? Give feedback.
-
Ended up with these. (Had to do a lot of business coding before really trying complete flow)
There is no way to use existing filters with refresh flow. (Even if there is, there is no way to init it with previously owned AT) |
Beta Was this translation helpful? Give feedback.
-
@ayhanap Hi, missed your last comment:
I think, given the previous discussion is that we are talking about some specific and fairly involved case/setup. Can you consider creating a reproducer ? I'll then have a look and we can make sure we are on the same line, as at the moment it feels like we are a bit out of sync :-) |
Beta Was this translation helpful? Give feedback.
-
@ayhanap Actually, I have reread it, so the existing filters will refresh the tokens with the current RT they are aware of. But, you are right, if you have an out of band refresh token saved in a DB, then, indeed, the filters are not aware of it, and therefore a customization is needed. If you see in your current work that there is something that we can improve in this regard, please open an issue :-) Thanks |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So here is my use case, which is very common I assume;
Tokens
object.So been through every issue and pretty much every source code of oidc-client. How to initialize an OidcClient with a previous refreshToken?
Beta Was this translation helpful? Give feedback.
All reactions