Skip to content

Add support for ephemeral session in Custom Tabs #863

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

Closed
wants to merge 4 commits into from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 21, 2025

This PR adds support for ephemeral browsing sessions in Custom Tabs, leveraging the functionality introduced in androidx.browser:browser:1.9.0. Ephemeral sessions enhance privacy and security by preventing the persistence of browsing data, cookies, or history during authentication flows.

Features Added

CustomTabsOptions Updates

  • Added ephemeralBrowsingEnabled field to store the ephemeral browsing preference
  • Added withEphemeralBrowsingEnabled(boolean) method in CustomTabsOptions.Builder to enable/disable ephemeral browsing
  • Updated toIntent() method to call setEphemeralBrowsingEnabled() on the CustomTabsIntent.Builder when the option is enabled
  • Updated Parcelable implementation to include the new field for proper state serialization/deserialization
  • Updated constructor and builder to handle the new parameter

WebAuthProvider Updates

  • Added enableEphemeralSession() method in WebAuthProvider.Builder to enable ephemeral browsing sessions with a simple API
  • This method creates CustomTabsOptions with ephemeral browsing enabled and sets it on the builder

API Usage

Recommended Approach (Simple)

WebAuthProvider.login(auth0)
    .enableEphemeralSession()
    .start(this, callback)

Advanced Approach (Full Control)

val customTabsOptions = CustomTabsOptions.newBuilder()
    .withEphemeralBrowsingEnabled(true)
    .withToolbarColor(R.color.primary)
    .showTitle(true)
    .build()

WebAuthProvider.login(auth0)
    .withCustomTabsOptions(customTabsOptions)
    .start(this, callback)

Benefits

  • Enhanced Privacy: Ephemeral sessions don't persist browsing data, cookies, or history
  • Better Security: Reduces risk of session data being accessed by other apps or users
  • User Control: Developers can choose when to use ephemeral sessions based on their security requirements
  • Backward Compatibility: When ephemeral browsing is not explicitly enabled, the behavior remains unchanged

Testing

  • Added comprehensive unit tests for the new functionality in CustomTabsOptionsTest.java
  • Added integration tests in WebAuthProviderTest.kt to verify the enableEphemeralSession() method
  • Updated existing tests to verify backward compatibility
  • Added tests to ensure proper Parcelable serialization/deserialization

The implementation follows the existing patterns in the codebase and maintains complete backward compatibility. When ephemeral browsing is not explicitly enabled, the behavior remains identical to the current implementation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.5-all/6qsw290k5lz422uaf8jf6m7co/gradle-7.5/lib/gradle-launcher-7.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.5 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add ephemeralBrowsingEnabled field to CustomTabsOptions
- Add withEphemeralBrowsingEnabled() method to CustomTabsOptions.Builder
- Update toIntent() method to call setEphemeralBrowsingEnabled()
- Update Parcelable implementation for new field
- Add enableEphemeralSession() method to WebAuthProvider.Builder
- Add comprehensive unit tests for new functionality
- Verify backward compatibility with default behavior

Co-authored-by: pmathew92 <[email protected]>
@Copilot Copilot AI changed the title [WIP] Add support for ephemeral session in Custom Tabs Add support for ephemeral session in Custom Tabs Aug 21, 2025
@Copilot Copilot AI requested a review from pmathew92 August 21, 2025 05:35
Copilot finished work on behalf of pmathew92 August 21, 2025 05:35
@pmathew92
Copy link
Contributor

Closing this PR as it was an experimental attempt

@pmathew92 pmathew92 closed this Aug 21, 2025
@pmathew92 pmathew92 reopened this Aug 21, 2025
@pmathew92 pmathew92 closed this Aug 21, 2025
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