Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OIDC FrontChannel logout #25343

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

sberyozkin
Copy link
Member

Fixes #23478

This PR supports a front-channel logout request. If the current request path matches the configured frontchannel logout URL then the sid and iss query parameters are compared against the verified ID token's values and if all is good then the session cookie is removed.

As part of this work I also moved the backchannel logout check from the earlier PR to the same stage where frontchannel logout URL is checked, after id token has been verified (instead of doing a limited token validation in the backchannel check code) - this allowed to include sending both the backchannel and frontchannel logout CDI events, referencing the identity of the now logged out user.

Wiremock based test has been added.

I can also try to do a manual verification directly against Keycloak (it is not possible to set up the frontchannel URL in the Client using the admin API)

@sberyozkin
Copy link
Member Author

Not sure if supporting POST requests is necessary, the spec talks about the query parameters only - but if needed it can be easily added. I'll test with Keycloak next

@sberyozkin
Copy link
Member Author

@pedroigor I haven't managed to confirm it with Keycloak - I have enabled FrontChannel logout and added a quarkus endpoint url which should be called. Then I logged in to Quarkus as alice, then started an RP initiated logout which redirected me to Keycloak but at this point I expected, not exactly sure what, I guess some page which would internally call to this Quarkus frontchannel logout path, but it does not happen.
How can one tell Keycloak to return a page to the user with the iframe calling out to Quarkus frontchannel logout URL ?

@sberyozkin
Copy link
Member Author

@tassadar81 Can you please check this PR and confirm it a front-channel logout works for you ? I can't make it work with Keycloak - I have configured Keycloak client to link to a Quarkus endpoint's frontchannel URL, and initiated a logout from Quarkus, however I'm not getting a frontchannel endpoint call, it is most likely to do with the way I'm trying to reproduce it, as far as this PR is concerned, it just adds a simple code to verify it is a valid frontchannel call

@gsmet
Copy link
Member

gsmet commented Jun 21, 2022

@tassadar81 any chance you could check if this PR works for you?

@tassadar81
Copy link

@tassadar81 any chance you could check if this PR works for you?

Hello Guillaume, hello all,
it's in the todo list, sorry for that but i'm overwhelmed at work

@sberyozkin sberyozkin force-pushed the oidc_frontchannel_logout branch from 04fd712 to 3dd5f84 Compare June 28, 2022 14:17
@gsmet
Copy link
Member

gsmet commented Aug 9, 2022

@sberyozkin this will need a rebase unfortunately
@tassadar81 friendly ping for the test, you should be able to test this branch even before the rebase

1 similar comment
@gsmet
Copy link
Member

gsmet commented Aug 31, 2022

@sberyozkin this will need a rebase unfortunately
@tassadar81 friendly ping for the test, you should be able to test this branch even before the rebase

@gsmet gsmet added the triage/needs-rebase This PR needs to be rebased first because it has merge conflicts label Aug 31, 2022
@geoand
Copy link
Contributor

geoand commented Nov 4, 2022

What's the status of this one?

@sberyozkin
Copy link
Member Author

@geoand Trying to finalize it next

@sberyozkin sberyozkin marked this pull request as draft November 24, 2022 19:36
@sberyozkin sberyozkin force-pushed the oidc_frontchannel_logout branch from 3dd5f84 to 3e90e9a Compare November 24, 2022 19:37
@sberyozkin
Copy link
Member Author

sberyozkin commented Nov 24, 2022

@pjgg Hi Pablo, FYI, this PR introduced a front-channel logout support, but along the way, as I mentioned earlier, events are generated for both initiating and completing back channel logout.
One test is failing now, I haven't had time to investigate yet, @michalvavrik, Hi Michal, quick question, this exception, which I have debugged is being thrown when this test line is run, but CodeAuthenticationMechanism#getChallenge is not invoked, it does appear to be similar to the problem you fixed with CodeFlowTest#testRPInitiatedLogout, do we need to tighten that fix a bit to take care of AuthenticationFailedException as well, when this PR was opened awhile back this test was passing. I'll be happy to have a look if you think it can be related, just hoping to clarify a few details first :-)

@michalvavrik
Copy link
Member

@michalvavrik, Hi Michal, quick question, this exception, which I have debugged is being thrown when this test line is run, but CodeAuthenticationMechanism#getChallenge is not invoked, it does appear to be similar to the problem you fixed with CodeFlowTest#testRPInitiatedLogout, do we need to tighten that fix a bit to take care of AuthenticationFailedException as well, when this PR was opened awhile back this test was passing. I'll be happy to have a look if you think it can be related, just hoping to clarify a few details first :-)

When AuthenticationFailedException is thrown here https://github.com/quarkusio/quarkus/pull/25343/files#diff-d6d40795b1093d6a39a62041f2567d0931b1f7fa30ebfea44e6663f45441df75R261, it's caught here

LOG.errorf("ID token verification failure: %s", t.getCause());
and AuthenticationCompletionException is thrown, thus 401 and no challenge. I didn't investigate why it worked before is it's bit late, but if you want me to have a look, no problem, please let me know.

@sberyozkin
Copy link
Member Author

@michalvavrik Oh sorry, should've guessed myself, I just got side-tracked by remembering your fix :-), I'll take care of fixing it. Thanks for having a look.

@sberyozkin sberyozkin force-pushed the oidc_frontchannel_logout branch from 3e90e9a to d6a40ce Compare November 25, 2022 12:00
@sberyozkin sberyozkin marked this pull request as ready for review November 25, 2022 12:00
@quarkus-bot

This comment has been minimized.

@sberyozkin
Copy link
Member Author

Sorry, forgot to include a new class in the commit

@sberyozkin sberyozkin force-pushed the oidc_frontchannel_logout branch from d6a40ce to 2df6ba4 Compare November 25, 2022 14:42
@sberyozkin sberyozkin added release/noteworthy-feature and removed triage/needs-rebase This PR needs to be rebased first because it has merge conflicts labels Nov 25, 2022
@sberyozkin
Copy link
Member Author

sberyozkin commented Nov 25, 2022

Hi @pjgg Can you please check this PR against your OIDC back channel demo, Pedro approved this PR awhile back and I only had to tweak it a bit for the tests to start passing again, but the backchannel code has changed compared to what you have been testing against: now the back channel logout can be completed only after the ID token has been verified, it is a bit stricter now, and in addition you can get backchannel initiate and completion CDI events - which you were interested in I believe.

Note the events are typically including a verified SecurityIdentity but with the back-channel initiation, when the request is coming from KC as opposed to from the user, SecurityIdentity is not available - so in this case one can get a JsonObject representing a parsed/verified logout token; the back-channel completion event will though get SecurityIdentity included - which is the main reason why the back channel logout completion now is done only after the ID token has been verified.

As far as the front-channel logout is concerned - it can be verified with a demo later, the PR wiremock test should be sufficient for now, I've added a release noteworthy label...
Thanks

@sberyozkin
Copy link
Member Author

sberyozkin commented Nov 25, 2022

OK, I'm going to go ahead and merge once the builds pass; it is not going to be backported so it is not urgent for QE to verify, Pablo is very busy elsewhere right now but it will be eventually verified as well in a few weeks or so

@sberyozkin sberyozkin merged commit 9a6b849 into quarkusio:main Nov 25, 2022
@sberyozkin sberyozkin deleted the oidc_frontchannel_logout branch November 25, 2022 18:29
@quarkus-bot quarkus-bot bot added this to the 2.15 - main milestone Nov 25, 2022
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quarkus oidc integration, frontchannel logout support
7 participants