[AuthTab] Rework Common to provider-based strategy selection (Option 1B, no browser 1.9 APIs), Fixes AB#3561426#3093
Conversation
|
✅ Work item link check complete. Description contains link AB#3561426 to an Azure Boards work item. |
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/58dbdb6e-1b72-41a7-9133-ef563e8c66ee Co-authored-by: p3dr0rv <76129899+p3dr0rv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/58dbdb6e-1b72-41a7-9133-ef563e8c66ee Co-authored-by: p3dr0rv <76129899+p3dr0rv@users.noreply.github.com>
|
@copilot |
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/3652c639-5565-464b-b6e8-bd816ec8526f Co-authored-by: p3dr0rv <76129899+p3dr0rv@users.noreply.github.com>
Fixed in 40930ec. I removed the nested typealiases in 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
…rowserActivityTest
There was a problem hiding this comment.
Pull request overview
Refactors the Switch Browser (AuthTab) integration in Common to avoid androidx.browser:browser:1.9+ APIs by selecting browser launch behavior via an externally-registered provider, while keeping a Custom Tabs fallback strategy within Common.
Changes:
- Introduces a provider registry (
AuthTabStrategyProvider) for Auth Tab support checks + strategy creation (no browser 1.9 APIs in Common). - Adds a
BrowserLaunchStrategyabstraction and aCustomTabsLaunchStrategyimplementation to encapsulate existing Custom Tabs launch/cleanup logic. - Updates
SwitchBrowserActivityto select AuthTab via provider when supported, otherwise fall back to Custom Tabs; adds focused Robolectric tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/AuthTabStrategyProvider.kt | Adds singleton registry for externally-provided AuthTab strategy/support checks. |
| common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/BrowserLaunchStrategy.kt | Adds strategy interface for browser launch, cancellation behavior, and cleanup. |
| common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/CustomTabsLaunchStrategy.kt | Extracts Custom Tabs launch/cleanup behavior behind the strategy interface. |
| common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/SwitchBrowserActivity.kt | Switches to provider-driven strategy selection + delegates lifecycle cleanup to strategy. |
| common/src/test/java/com/microsoft/identity/common/internal/providers/oauth2/AuthTabStrategyProviderTest.kt | Adds tests for provider registration, delegation, and default/unavailable behavior. |
| common/src/test/java/com/microsoft/identity/common/internal/providers/oauth2/SwitchBrowserActivityTest.kt | Adds tests for strategy selection (provider path + Custom Tabs fallback). |
| common/build.gradle | Updates MockK test dependency version. |
…elated functionality
…n object for strategy and support checker, enhancing thread safety. Update tests to verify behavior with fallback strategies.
…ctivity creation, ensuring accurate verification of strategy launches.
…or across environments by using a mock flights provider. Remove unnecessary looper idling during activity creation.
…or deterministic flight behavior across environments, replacing the previous MockCommonFlightsManager implementation.
|
@copilot UPDATE CHANGELOG |
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/53bb72ec-e08a-4a79-8c2e-a30206ecbfd0 Co-authored-by: p3dr0rv <76129899+p3dr0rv@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/53bb72ec-e08a-4a79-8c2e-a30206ecbfd0 Co-authored-by: p3dr0rv <76129899+p3dr0rv@users.noreply.github.com>
Updated in 161b5a0. Added the vNext changelog entry for the AuthTab provider-based strategy selection rework. 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
This PR implements the Common-side of Auth Tab support for the switch-browser flow using Option 1B — a provider-based architecture that keeps Common free of
browser:1.9.0dependencies.Why Option 1B?
Common uses
androidx.browser:browser:1.7.0. Auth Tab requiresbrowser:1.9.0. Bumping Common to 1.9.0 would cascade to MSAL, OneAuth, and ADAL. Instead, Common defines interfaces and a registry; Broker (which already hasbrowser:1.9.0) provides the implementation at runtime.Architecture
graph TB subgraph "Common module · browser:1.7.0" SBA["SwitchBrowserActivity"] ATSP["AuthTabStrategyProvider\n(singleton registry)"] BLS["«interface»\nBrowserLaunchStrategy"] CTLS["CustomTabsLaunchStrategy\n(fallback)"] SBA -->|"1. isAuthTabSupported?"| ATSP SBA -->|"2. createStrategy() or fallback"| ATSP ATSP -.->|"delegates to registered impl"| BLS SBA -->|"fallback"| CTLS CTLS -.->|implements| BLS end subgraph "Broker module · browser:1.9.0" ATLS["AuthTabLaunchStrategy"] ATM["AuthTabManager"] REG["AuthTabRegistration"] ATLS -.->|implements| BLS ATLS -->|uses| ATM ATM -->|"wraps"| ATI["AuthTabIntent API\n(browser 1.9.0)"] REG -->|"register(factory, isSupported)"| ATSP end BCP["BrokerContentProvider\n.onCreate()"] -->|"calls at process init"| REG style ATSP fill:#4a9eff,color:#fff style BLS fill:#2d7d46,color:#fff style CTLS fill:#2d7d46,color:#fff style ATLS fill:#c75000,color:#fff style ATM fill:#c75000,color:#fff style REG fill:#c75000,color:#fffRuntime Flow
sequenceDiagram participant BCP as BrokerContentProvider participant REG as AuthTabRegistration participant ATSP as AuthTabStrategyProvider participant SBA as SwitchBrowserActivity participant ATLS as AuthTabLaunchStrategy participant CTLS as CustomTabsLaunchStrategy Note over BCP: App process starts BCP->>REG: onCreate() REG->>ATSP: register(factory, isSupported) Note over SBA: eSTS returns switch_browser SBA->>ATSP: isAuthTabSupported(ctx, browserPkg)? alt Auth Tab supported ATSP-->>SBA: true SBA->>ATSP: createStrategy(activity, onResult) ATSP-->>SBA: AuthTabLaunchStrategy SBA->>ATLS: launch() ATLS-->>SBA: result via callback else Auth Tab not supported / not registered ATSP-->>SBA: false SBA->>CTLS: new CustomTabsLaunchStrategy() SBA->>CTLS: launch() Note over SBA: Handles cancel via onResume endWhat Changed
New Files
AuthTabStrategyProvider.ktBrowserLaunchStrategy.ktlaunch(),handlesCancellationOnResume(),cleanup()CustomTabsLaunchStrategy.ktBrowserLaunchStrategyinterface (fallback path)AuthTabStrategyProviderTest.ktSwitchBrowserActivityTest.ktModified Files
SwitchBrowserActivity.ktonCreate()to queryAuthTabStrategyProviderfor strategy selection instead of hardcoded Custom Tabs pathSwitchBrowserChallenge.ktSwitchBrowserRequestHandler.ktSwitchBrowserChallengeSwitchBrowserUriHelper.ktbuildResumeBrowserUri()helper for constructing the redirect URI used by Auth TabSwitchBrowserProtocolCoordinator.ktSwitchBrowserUriHelper)SpanName.javaKey Design Decisions
AuthTabStrategyProviderstores the factory + support checker in a single@Volatiledata class reference, preventing half-registered states in multi-threaded scenariosandroid.content.Context,FragmentActivity, andBundlein its provider API. AllAuthTabIntent/CustomTabsClient.isAuthTabSupportedcalls live in BrokerSwitchBrowserActivityfalls back toCustomTabsLaunchStrategyautomaticallyFixes AB#3561426