Skip to content

Conversation

@lovasoa
Copy link
Collaborator

@lovasoa lovasoa commented Dec 2, 2025

Add a secure OIDC logout endpoint and a sqlpage.oidc_logout_url function to provide CSRF-protected logout functionality.

The logout endpoint uses HMAC-signed tokens for CSRF protection, as SQLPage functions cannot directly set cookies for traditional CSRF tokens. This ensures the logout link is self-verifying and secure. It also handles redirection to the OIDC provider's end_session_endpoint if available, otherwise performs local logout.


Open in Cursor Open in Web

cursoragent and others added 5 commits December 2, 2025 22:31
This commit introduces the `oidc_logout_url` function, allowing users to securely log out of OIDC-authenticated applications. It includes CSRF protection and handles redirection to the OIDC provider's logout endpoint.

Co-authored-by: contact <[email protected]>
@cursor
Copy link

cursor bot commented Dec 2, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@lovasoa lovasoa marked this pull request as ready for review December 3, 2025 09:42
cursoragent and others added 8 commits December 3, 2025 09:45
This commit implements secure OIDC logout by:

- Using sqlpage.oidc_logout_url() to generate the logout URL.
- Ensuring CSRF protection during the logout process.
- Redirecting to the OIDC provider's logout endpoint.
- Redirecting back to the homepage after logout.
- Adding absolute URI for post logout redirect URI.
This commit modifies the build_absolute_uri function to include a scheme parameter, allowing for more flexible URL construction. The function now dynamically sets the URL scheme based on the request context, improving compatibility with different environments.
…ndling

This commit refactors the OIDC logout process by introducing a new function, `parse_logout_params`, to streamline the extraction of logout parameters from the request. It also updates the logout token creation and verification logic, improving security by ensuring the signature is computed correctly. Additionally, the `create_logout_url` function is modified to include a timestamp and signature in the generated URL, enhancing the logout flow's integrity.
This commit refines the `create_logout_url` function to utilize a query string builder for constructing the logout URL, enhancing readability and maintainability. Additionally, the `parse_logout_params` function is updated to use `Query::into_inner`, streamlining the extraction of logout parameters from the request.
This commit simplifies the removal of authentication and nonce cookies during the OIDC logout process by consolidating the cookie removal logic into a single method call for each cookie, enhancing code clarity and maintainability.
This commit updates the cookie removal process during OIDC logout by utilizing the `Cookie::build` method to specify cookie attributes, improving clarity and ensuring proper cookie handling.
- Added new function `sqlpage.oidc_logout_url(redirect_uri)` to generate secure logout URLs for OIDC users, supporting RP-Initiated Logout.
- Fixed compatibility issues with Auth0 for OpenID-Connect authentication.
@lovasoa lovasoa merged commit 083593d into main Dec 7, 2025
11 checks passed
@lovasoa lovasoa deleted the cursor/implement-secure-oidc-logout-endpoint-and-sql-function-claude-4.5-opus-high-thinking-47fd branch December 7, 2025 00:06
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.

3 participants