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

logout to upstream OIDC Provider when logging out from MAS #4249

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mcalinghee
Copy link
Contributor

@mcalinghee mcalinghee commented Mar 17, 2025

When logging out from MAS we would like to have the ability end the session on the upstream OIDC provider according to the spec : https://openid.net/specs/openid-connect-rpinitiated-1_0.html

If allow_rp_initiated_logout is set to true, this will end the session on the upstream provider when logging out from MAS.

@mcalinghee mcalinghee force-pushed the feat/upstream_logout_end_session branch 8 times, most recently from a2ac44f to a53c9b4 Compare March 20, 2025 10:26
@mcalinghee mcalinghee marked this pull request as ready for review March 20, 2025 10:27
@mcalinghee mcalinghee changed the title support RP initiated logout to upstream OIDC Provider when logging out from MAS logout to upstream OIDC Provider when logging out from MAS Mar 20, 2025
@mcalinghee mcalinghee force-pushed the feat/upstream_logout_end_session branch 3 times, most recently from 695af90 to 0f90080 Compare March 25, 2025 15:27
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! This isn't a full review, rather a quick look with a few suggestions

.to_string();
result.post_logout_redirect_uri = Some(post_logout_redirect_uri.clone());

let sessions_cookie = UpstreamSessionsCookie::load(cookie_jar);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading from the cookie is unreliable. You should instead:

  • lookup the authentications for the current user_session in the user_session_authentications
  • authentications that were done through an upstream will have a reference to a upstream_oauth_authorization_session_id
  • there you can grab the id_token received during the auth and extract the subject
  • you should also pass the id_token to the RP-initiated logout endpoint through the id_token_hint

Copy link
Contributor Author

@mcalinghee mcalinghee Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review!
I have amended the code but I was not sure if I needed to extract the subject to perform the logout

@@ -39,6 +41,22 @@ pub(crate) async fn post(
.record_browser_session(&clock, &session)
.await;

// First, get RP-initiated logout endpoints before actually finishing the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure that this logic also happens when the logout is done through the React frontend. I don't have a good suggestion on how to do so for now though

Copy link
Contributor Author

@mcalinghee mcalinghee Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking on how to integrate this here but I am not sure this is the way to go

We need to do a redirect to the upsteam end_session_endpoint.
We might also need to integrate some component in the State to perform such as a http client to get/discover the URL.

Let me what your thoughts are.

@mcalinghee mcalinghee force-pushed the feat/upstream_logout_end_session branch 4 times, most recently from d32d837 to 7defa02 Compare April 8, 2025 13:22
@mcalinghee mcalinghee force-pushed the feat/upstream_logout_end_session branch 2 times, most recently from bf1b470 to 8e1e912 Compare April 11, 2025 06:40
@mcalinghee mcalinghee force-pushed the feat/upstream_logout_end_session branch from 8e1e912 to 648a390 Compare April 11, 2025 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants