Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ else if (isRedirectUrl(formattedURL)) {
processWebCpEnrollmentUrl(view, url);
} else if (mIsWebCpInWebViewFeatureEnabled && isWebCpAuthorizeUrl(url)) {
processWebCpAuthorize(view, url);
} else if (isDeviceCaRequest(url)) {
// Special handling for device CA requests due to a corner case in eSTS for webapps/confidential clients, which should be handled by the WebView.
processDeviceCaRequest(view, url);
} else {
Logger.info(methodTag,"This maybe a valid URI, but no special handling for this mentioned URI, hence deferring to WebView for loading.");
processInvalidUrl(url);
Expand Down Expand Up @@ -575,29 +578,34 @@ private void processWebsiteRequest(@NonNull final WebView view, @NonNull final S
view.stopLoading();

if (isDeviceCaRequest(url)) {
Logger.info(methodTag, "This is a device CA request.");

if (shouldLaunchCompanyPortal()) {
// If CP is installed, redirect to CP.
// TODO: Until we get a signal from eSTS that CP is the MDM app, we cannot assume that.
// CP is currently working on this.
// Until that comes, we'll only handle this in ipphone.
try {
launchCompanyPortal();
return;
} catch (final Exception ex) {
Logger.warn(methodTag, "Failed to launch Company Portal, falling back to browser.");
}
}

loadDeviceCaUrl(url, view);
processDeviceCaRequest(view, url);
} else {
Logger.info(methodTag, "Not a device CA request. Redirecting to browser.");
openLinkInBrowser(url);
returnResult(RawAuthorizationResult.ResultCode.CANCELLED);
}
}

private void processDeviceCaRequest(@NonNull final WebView view, @NonNull final String url) {
final String methodTag = TAG + ":handleDeviceCaRequest";
Logger.info(methodTag, "This is a device CA request.");

if (shouldLaunchCompanyPortal()) {
// If CP is installed, redirect to CP.
// TODO: Until we get a signal from eSTS that CP is the MDM app, we cannot assume that.
// CP is currently working on this.
// Until that comes, we'll only handle this in ipphone.
try {
launchCompanyPortal();
return;
} catch (final Exception ex) {
Logger.warn(methodTag, "Failed to launch Company Portal, falling back to browser.");
}
}

loadDeviceCaUrl(url, view);
}

private boolean isDeviceCaRequest(@NonNull final String url) {
return url.contains(AuthenticationConstants.Broker.BROWSER_DEVICE_CA_URL_QUERY_STRING_PARAMETER);
}
Expand Down Expand Up @@ -647,6 +655,7 @@ protected boolean isWebCpInWebviewFeatureEnabled(@NonNull final String originalU
try {
if (!ProcessUtil.isRunningOnAuthService(getActivity().getApplicationContext())) {
// Enabling webcp in webview feature for brokered flows only for now.
Logger.info(methodTag, "Not running on AuthService, skipping WebCP in WebView feature check.");
return false;
}

Expand All @@ -662,7 +671,7 @@ protected boolean isWebCpInWebviewFeatureEnabled(@NonNull final String originalU
SpanExtension.current().setAttribute(AttributeName.web_cp_flight_get_time.name(), (System.currentTimeMillis() - webCpGetFlightStartTime));
if (isWebCpFlightEnabled) {
// Directly enabled via flight rollout.
Logger.info(methodTag, "WebCP in WebView feature is enabled. ");
Logger.info(methodTag, "WebCP in WebView feature is enabled.");
mIsWebCpInWebViewFeatureEnabled = true;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class AzureActiveDirectoryWebViewClientTest {
private static final String TEST_REDIRECT_URL = "ABC12/xyz";
private static final String TEST_WEBSITE_REQUEST_URL = "browser://abcxyz/a";
private static final String TEST_BROWSER_DEVICE_CA_URL_QUERY_STRING_PARAMETER = "browser://abcxyz/xyz&ismdmurl=1";

private static final String TEST_HTTPS_DEVICE_CA_URL_QUERY_STRING_PARAMETER = "https://abcxyz/xyz&ismdmurl=1";
private static final String TEST_INSTALL_REQUEST_URL = "msauth://wpj/?username=someusername%somedomain.onmicrosoft.com&app_link=https%3a%2f%2fplay.google.com%2fstore%2fapps%2fdetails%3fid%3dcom.azure.authenticator%26referrer%3dcom.msft.identity.client.sample.local";
private static final String TEST_DEVICE_REGISTRATION_URL = "msauth://wpj/?username=someusername%somedomain.onmicrosoft.com";
private static final String TEST_BLANK_PAGE_REQUEST_URL = "about:blank";
Expand Down Expand Up @@ -170,6 +172,11 @@ public void testUrlOverrideHandlesWebsiteRequestUrl() {
assertTrue(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, TEST_BROWSER_DEVICE_CA_URL_QUERY_STRING_PARAMETER));
}

@Test
public void testUrlOverrideHandlesHttpsDeviceCARequestUrl() {
assertTrue(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, TEST_HTTPS_DEVICE_CA_URL_QUERY_STRING_PARAMETER));
}

@Test
public void testUrlOverrideHandlesInstallRequest() {
assertTrue(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, TEST_INSTALL_REQUEST_URL));
Expand Down
Loading