quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.39k stars 2.56k forks source link

Quarkus OIDC Client: Lazy OIDC Discovery #39293

Open mkomadel opened 4 months ago

mkomadel commented 4 months ago

Description

When using quarkus-oidc-client extension, OIDC discovery is executed on application startup, which causes errors when the OIDC server is down at the time.

It would be nice to have an option to enable "lazy" discovery which would be executed once OidcClient ist first used.

Implementation ideas

I am no expert in mutiny but, maybe putting the tokenRequestUri in an Uni could be the solution. On eager OIDC discovery, it would contain the value, on lazy discovery http calls would be triggered (and the result saved using some kind of shareReplay mutiny alternative).

quarkus-bot[bot] commented 4 months ago

/cc @pedroigor (oidc), @sberyozkin (oidc)

sberyozkin commented 4 months ago

@mkomadel Can you check if avoiding the discovery with setting quarkus.oidc-client.token-path=absolute_token_uri and, only if you use RestEasy Classic, quarkus.oidc-client.early-tokens-acquisition=false, solves the problem ?

I don't mind retrying the OidcClient connection request if it failed during the bootstrap time, as we do with quarkus-oidc but the above suggestion should offer a simple workaround

mkomadel commented 4 months ago

@sberyozkin yes that is what I am doing at the moment and it works. But quarkus.oidc-client.token-path avoids doing the discovery, that is why I wrote this enhancement.