Skip to content

Conversation

@mcalinghee
Copy link
Contributor

@mcalinghee mcalinghee commented Oct 10, 2025

Contexte

Add end_session endpoint to perform a RP-Initiated Logout according to the spec : https://openid.net/specs/openid-connect-rpinitiated-1_0.html

This endpoint will allow clients to disconnect from the MAS when they perform a log out.

NOTE :

  • no logout of upstream oauth2 session is performed

@mcalinghee mcalinghee changed the title add end_session endpoint to perform rp_initiated_logout Expose end_session endpoint to perform rp_initiated_logout Oct 10, 2025
@mcalinghee mcalinghee force-pushed the element-hq/rp_initiated_logout branch from 59b1593 to 701d48a Compare October 23, 2025 08:03
@mcalinghee
Copy link
Contributor Author

mcalinghee commented Oct 23, 2025

@mcalinghee mcalinghee force-pushed the element-hq/rp_initiated_logout branch from 59b1593 to 701d48a
27 minutes ago

sorry performed a rebase branch by mistake instead of merge branch to update the branch

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 working on this! Generally agree with having this, but there are a few things to get right

Comment on lines 52 to 53
// #[error("unsupported token type")]
// UnsupportedTokenType,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// #[error("unsupported token type")]
// UnsupportedTokenType,

)
.into_response(),

// Self::ClientNotAllowed |
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Self::ClientNotAllowed |

Comment on lines 89 to 94
// Self::UnsupportedTokenType => (
// StatusCode::BAD_REQUEST,
// Json(ClientError::from(ClientErrorCode::UnsupportedTokenType)),
// )
// .into_response(),

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Self::UnsupportedTokenType => (
// StatusCode::BAD_REQUEST,
// Json(ClientError::from(ClientErrorCode::UnsupportedTokenType)),
// )
// .into_response(),

Comment on lines +132 to +136
let oauth_session = repo
.oauth2_session()
.find_by_browser_session(browser_session.id)
.await?
.ok_or(RouteError::BadRequest)?;
Copy link
Member

Choose a reason for hiding this comment

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

You can have many OAuth session started from a single browser session, so this way is not the right approach here.

Instead, best is to decode the JWT (but not necessarily verify it, maybe verify_id_token should be changed a little bit?) to get the claims we need and go from there? I'm unclear what we should be checking exactly on that JWT though, I don't know whether there is something that would let us link it to the current browser session or not 🤔

}

// Now that we checked everything, we can end the session.
repo.oauth2_session().finish(&clock, oauth_session).await?;
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about that semantic. I don't know whether we should finish the oauth session at this point or let the client still call the revocation endpoint.

Either way, we need a better way to find the right OAuth session, and I think this should be done by injecting the OAuth session ID in the id_token sid claim when we give out the id_token

// invalid
let cookie_jar = cookie_jar.update_session_info(&session_info.mark_session_ended());

Ok((cookie_jar, Redirect::to(&params.post_logout_redirect_uri)).into_response())
Copy link
Member

Choose a reason for hiding this comment

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

The spec says we really should be validating the post_logout_redirect_uri, it should be registered by the client first

The value MUST have been previously registered with the OP, either using the post_logout_redirect_uris Registration parameter or via another mechanism.

// .into_response(),

// If the token is unknown, we still return a 200 OK response.
Self::UnknownToken => StatusCode::OK.into_response(),
Copy link
Member

Choose a reason for hiding this comment

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

We should have a nice view in some of those cases, in the end that is going to be a redirect, potentially where it doesn't go back to the client

@mcalinghee mcalinghee requested a review from a team as a code owner November 6, 2025 10:29
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