-
Notifications
You must be signed in to change notification settings - Fork 180
feat: enable ephemeral browsing for Auth Tab #1059
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,17 @@ Intent toIntent(@NonNull Context context, @Nullable CustomTabsSession session) { | |
| @SuppressLint("ResourceType") | ||
| AuthTabIntent.Builder toAuthTabIntentBuilder(@NonNull Context context) { | ||
| AuthTabIntent.Builder builder = new AuthTabIntent.Builder(); | ||
| if (ephemeralBrowsing) { | ||
| String preferredPackage = this.getPreferredPackage(context.getPackageManager()); | ||
| if (preferredPackage != null | ||
| && CustomTabsClient.isEphemeralBrowsingSupported(context, preferredPackage)) { | ||
| builder.setEphemeralBrowsingEnabled(true); | ||
|
Comment on lines
+200
to
+204
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
# Map the changed type, then inspect every Auth Tab construction and launch path.
ast-grep outline auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java --items all
rg -n -C 12 --glob '*.{java,kt}' \
'toAuthTabIntentBuilder\s*\(|AuthTabIntent|setPackage\s*\(|setSession\s*\(|\.launch\s*\(' \
auth0/src/main auth0/src/test
# Verify that the package checked by getPreferredPackage is applied to the final
# AuthTabIntent before launch, or that a session from that same provider is used.Repository: auth0/Auth0.Android Length of output: 50375 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- CustomTabsOptions ---'
sed -n '90,125p;197,225p' auth0/src/main/java/com/auth0/android/provider/CustomTabsOptions.java
printf '%s\n' '--- CustomTabsController launch and binding ---'
sed -n '90,230p' auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java
printf '%s\n' '--- BrowserPicker selection contract ---'
sed -n '70,180p' auth0/src/main/java/com/auth0/android/provider/BrowserPicker.java
printf '%s\n' '--- focused Auth Tab tests ---'
sed -n '350,470p' auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.javaRepository: auth0/Auth0.Android Length of output: 19980 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- CustomTabsController state, constructor, and service callbacks ---'
sed -n '1,105p' auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java
sed -n '230,360p' auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java
printf '%s\n' '--- Auth Tab dependency/version declarations ---'
rg -n -C 3 'androidx\.browser|browserVersion|browser:' --glob '*.{gradle,gradle.kts,properties,toml,xml}' .Repository: auth0/Auth0.Android Length of output: 4785 🌐 Web query:
💡 Result: In AndroidX Browser 1.10.0, the AuthTabIntent.Builder class provides the setSession(AuthTabSession session) method to associate an intent with a specific session [1][2]. When this session is set, the library guarantees that the intent will be sent to the same browser component associated with that session [1][2]. This mechanism effectively performs package pinning for the authentication flow, ensuring continuity by forcing the Auth Tab to launch within the specific browser process that initiated the session [1][2]. Key details regarding this functionality in version 1.10.0 include: Session Association: The setSession method links the AuthTabIntent to an AuthTabSession instance [1][2]. By calling this, you ensure the Auth Tab is handled by the exact same component linked to the session, preventing the Intent from being intercepted or handled by a different browser [1][2]. Recent Fixes: Version 1.10.0 included specific fixes related to session support in the Auth Tab (commit I4e280), ensuring that these associations are correctly respected during the launch process [3][4]. Usage: 1. Create an AuthTabSession instance. 2. Use AuthTabIntent.Builder.setSession(session).build to create your intent [1][2]. 3. Call the launch method on the resulting AuthTabIntent object using your registered ActivityResultLauncher [5][6]. This approach is the standard way to maintain a persistent and secure context across authentication steps, as the underlying session management restricts the launch target to the intended, verified browser [1][7]. Citations:
Do not launch an unpinned Auth Tab when the service session is unavailable.
🤖 Prompt for AI Agents |
||
| } else { | ||
| Log.w(TAG, "Ephemeral browsing was requested but is not supported by the " | ||
| + "current browser (" + preferredPackage + "). " | ||
| + "Falling back to a regular Auth Tab."); | ||
| } | ||
| } | ||
| if (toolbarColor > 0) { | ||
| final AuthTabColorSchemeParams params = new AuthTabColorSchemeParams.Builder() | ||
| .setToolbarColor(ContextCompat.getColor(context, toolbarColor)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add Kotlin and Java examples for ephemeral Auth Tab.
Line 409 documents the new Auth Tab behavior. Add examples that combine
withAuthTab()andwithEphemeralBrowsing()in both languages. The existing separate examples do not show the required option combination.As per coding guidelines, “Document public API and behavior changes: update EXAMPLES.md with Kotlin and Java usage.”
🤖 Prompt for AI Agents
Source: Coding guidelines