-
Notifications
You must be signed in to change notification settings - Fork 46
Fix for App Link Usage in DUNA / SSO scenarios #2745
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
Conversation
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
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.
Pull Request Overview
This PR fixes an issue where app link redirect URIs used from within Chrome Custom Tabs (CCT) may not properly redirect to the native app when cookies are present at the IdP and there's no user interaction. The solution involves upgrading the androidx.browser library from version 1.0.0 to 1.7.0 and enabling the EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER flag.
Key changes:
- Upgraded androidx.browser library from 1.0.0 to 1.7.0 to access the required CCT flag
- Enabled setSendToExternalDefaultHandlerEnabled flag in CustomTabsManager to fix app link redirection
- Replaced deprecated LocalBroadcastManager with system broadcast receiver registration
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| gradle/versions.gradle | Updates androidx.browser library version from 1.0.0 to 1.7.0 |
| CustomTabsManager.java | Adds setSendToExternalDefaultHandlerEnabled(true) to fix app link redirection |
| CurrentTaskAuthorizationActivity.java | Replaces LocalBroadcastManager with system broadcast receiver and adds API level compatibility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...om/microsoft/identity/common/internal/providers/oauth2/CurrentTaskAuthorizationActivity.java
Outdated
Show resolved
Hide resolved
...om/microsoft/identity/common/internal/providers/oauth2/CurrentTaskAuthorizationActivity.java
Show resolved
Hide resolved
…Fixes AB#3387976 (#2775) Fixes [AB#3387976](https://dev.azure.com/IdentityDivision/Engineering/_workitems/edit/3387976) The previous fix seems to have addressed the issue only partially. Previous fix: #2745 Basically what's happening is that even with that flag CCT will sometimes still launch the URL in browser and this is happening because we're setting the browser's pkg name explicitly on the intent which tells the OS that this MUST be opened in the browser. Checked CCT logs and they print something like: `Launching in browser as Browser pkg was explicitly set on the Intent` Once we remove the explicit pkg name then OS finds the best possible app on the device to handle the intent. For an app link that's the the broker hosting app.
Issue: When app link redirect URI is used from within CCT then CCT may not redirect to the native app to handle the redirect and instead open it directly within the browser. From experience I've seen this happen there are existing cookies present at the IdP and there is no user interaction.
Solution: Per this chromium thread, the solution is set a flag when launching CCT called as EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER.
That flag was actually introduced in
androidx.browserlibrary version1.7.0and we were on a very ancient version (1.0.0). So this PR updates that library version to1.7.0As a side effect of that upgrade we can no longer use LocalBroadcastManager API (it's deprecated). So I've updated that accordingly similar to what @p3dr0rv was doing earlier when he tried upgrading browser library to 1.9.0 (which we couldn't do due to requiring compile sdk 36)