Skip to content

Conversation

michaelstingl
Copy link
Contributor

@michaelstingl michaelstingl commented Jul 8, 2025

Description

This PR implements OAuth2/OIDC logout functionality in the iOS SDK. It adds proper token revocation support for OAuth2 (RFC 7009) and OIDC end session support, ensuring users are fully logged out at the identity provider level.

OAuth2 Implementation

  • Added deauthenticateConnection:withCompletionHandler: method to OCAuthenticationMethodOAuth2
  • Implemented token revocation according to RFC 7009
  • Added revocationEndpointURLForConnection:options: for endpoint discovery
  • Supports client credentials in Authorization header or POST body

OIDC Implementation

  • Overrides deauthenticateConnection to use OIDC's end_session_endpoint
  • Builds logout URL with id_token_hint, post_logout_redirect_uri, and state
  • Uses ASWebAuthenticationSession for logout flow
  • Falls back to OAuth2 token revocation if no end_session_endpoint

Related Issue

Currently no issue exists for this feature. This addresses the missing logout functionality where users remain logged in at the IdP level after removing bookmarks.

Motivation and Context

The iOS app currently only removes local data when deleting bookmarks but doesn't perform proper logout at the identity provider. This is inconsistent with the web client behavior and leaves active sessions on the server.

How Has This Been Tested?

  • Manual testing with ownCloud 10 (OAuth2)
  • Manual testing with oCIS (OIDC)
  • Testing with external OIDC providers
  • Verified tokens are invalidated after logout
  • Tested fallback behavior when endpoints unavailable

Screenshots (if appropriate):

N/A - Backend functionality

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Implement deauthenticateConnection method in OCAuthenticationMethodOAuth2 with token revocation (RFC 7009)
- Add revocationEndpointURLForConnection method for endpoint discovery
- Override deauthenticateConnection in OCAuthenticationMethodOpenIDConnect to use OIDC end_session_endpoint
- Support proper OIDC logout flow with id_token_hint and post_logout_redirect_uri
- Clear all authentication data and OIDC configuration on logout
- Fallback to OAuth2 token revocation when OIDC logout endpoint not available

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
michaelstingl and others added 3 commits July 8, 2025 22:31
- Add OCAuthenticationMethodOpenIDConnectPostLogoutRedirectURI class setting
- Document the setting with proper metadata for auto-documentation
- Default to empty string, falls back to redirect URI if not configured
- Allows customization of post-logout redirect behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Use connection.authSignals instead of connection.bookmark.certificateStore.requiredSignals
to match the pattern used in other authentication requests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Use setValue:forHeaderField: instead of non-existent authorizationHeaderValue property

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

1 participant