Skip to content

Commit f0e4b27

Browse files
authored
Merge pull request #224034 from henrymbuguakiarie/msid-freshnes-2023-msal-android-single-sign-on
[msid][content-health][freshness] msal-android-single-sign-on (ADO-59512)
2 parents a08f6d4 + 6828fb6 commit f0e4b27

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

articles/active-directory/develop/msal-android-single-sign-on.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ ms.workload: identity
1111
ms.tgt_pltfrm: android
1212
ms.devlang: java
1313
ms.topic: how-to
14-
ms.date: 10/15/2020
14+
ms.date: 01/18/2023
1515
ms.author: henrymbugua
16-
ms.reviewer: marsma
1716
---
1817

1918
# Enable cross-app SSO on Android using MSAL
@@ -28,35 +27,34 @@ In this how-to, you'll learn how to configure the SDKs used by your application
2827

2928
This how-to assumes you know how to:
3029

31-
- Provision your app using the Azure portal. For more information on this topic, see the instructions for creating an app in [the Android tutorial](./tutorial-v2-android.md#create-a-project)
32-
- Integrate your application with the [Microsoft Authentication Library for Android](https://github.com/AzureAD/microsoft-authentication-library-for-android).
30+
- Provision your app using the Azure portal. For more information, see the instructions for creating an app in [the Android tutorial](./tutorial-v2-android.md#create-a-project)
31+
- Integrate your application with the [MSAL for Android](https://github.com/AzureAD/microsoft-authentication-library-for-android)
3332

34-
## Methods for single sign-on
33+
## Methods for SSO
3534

3635
There are two ways for applications using MSAL for Android to achieve SSO:
3736

38-
* Through a [broker application](#sso-through-brokered-authentication)
39-
* Through the [system browser](#sso-through-system-browser)
37+
- Through a [broker application](#sso-through-brokered-authentication)
38+
- Through the [system browser](#sso-through-system-browser)
4039

41-
42-
It is recommended to use a broker application for benefits like device-wide SSO, account management, and conditional access. However, it requires your users to download additional applications.
40+
It's recommended to use a broker application for benefits like device-wide SSO, account management, and conditional access. However, it requires your users to download additional applications.
4341

4442
## SSO through brokered authentication
4543

46-
We recommend that you use one of Microsoft's authentication brokers to participate in device-wide single sign-on (SSO) and to meet organizational Conditional Access policies. Integrating with a broker provides the following benefits:
44+
We recommend that you use one of Microsoft's authentication brokers to participate in device-wide SSO and to meet organizational Conditional Access policies. Integrating with a broker provides the following benefits:
4745

48-
- Device single sign-on
46+
- Device SSO
4947
- Conditional Access for:
5048
- Intune App Protection
5149
- Device Registration (Workplace Join)
5250
- Mobile Device Management
5351
- Device-wide Account Management
54-
- via Android AccountManager & Account Settings
52+
- via Android AccountManager & Account Settings
5553
- "Work Account" - custom account type
5654

5755
On Android, the Microsoft Authentication Broker is a component that's included in the [Microsoft Authenticator](https://play.google.com/store/apps/details?id=com.azure.authenticator) and [Intune Company Portal](https://play.google.com/store/apps/details?id=com.microsoft.windowsintune.companyportal) apps.
5856

59-
The following diagram illustrates the relationship between your app, the Microsoft Authentication Library (MSAL), and Microsoft's authentication brokers.
57+
The following diagram illustrates the relationship between your app, the MSAL, and Microsoft's authentication brokers.
6058

6159
![Diagram showing how an application relates to MSAL, broker apps, and the Android account manager.](./media/brokered-auth/brokered-deployment-diagram.png)
6260

@@ -74,7 +72,7 @@ If a device doesn't already have a broker app installed, MSAL instructs the user
7472

7573
#### When a broker is installed
7674

77-
When a broker is installed on a device, all subsequent interactive token requests (calls to `acquireToken()`) are handled by the broker rather than locally by MSAL. Any SSO state previously available to MSAL is not available to the broker. As a result, the user will need to authenticate again, or select an account from the existing list of accounts known to the device.
75+
When a broker is installed on a device, all subsequent interactive token requests (calls to `acquireToken()`) are handled by the broker rather than locally by MSAL. Any SSO state previously available to MSAL isn't available to the broker. As a result, the user will need to authenticate again, or select an account from the existing list of accounts known to the device.
7876

7977
Installing a broker doesn't require the user to sign in again. Only when the user needs to resolve an `MsalUiRequiredException` will the next request go to the broker. `MsalUiRequiredException` can be thrown for several reasons, and needs to be resolved interactively. For example:
8078

@@ -86,9 +84,9 @@ Installing a broker doesn't require the user to sign in again. Only when the use
8684

8785
#### When a broker is uninstalled
8886

89-
If there is only one broker hosting app installed, and it is removed, then the user will need to sign in again. Uninstalling the active broker removes the account and associated tokens from the device.
87+
If there's only one broker hosting app installed, and it's removed, then the user will need to sign in again. Uninstalling the active broker removes the account and associated tokens from the device.
9088

91-
If Intune Company Portal is installed and is operating as the active broker, and Microsoft Authenticator is also installed, then if the Intune Company Portal (active broker) is uninstalled the user will need to sign in again. Once they sign in again, the Microsoft Authenticator app becomes the active broker.
89+
If Intune Company Portal is installed and is operating as the active broker, and Microsoft Authenticator is also installed, then if the Intune Company Portal (active broker) is uninstalled the user will need to sign in again. Once they sign in again, the Microsoft Authenticator app becomes the active broker.
9290

9391
### Integrating with a broker
9492

@@ -112,10 +110,14 @@ Windows:
112110
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
113111
```
114112

115-
Once you've generated a signature hash with *keytool*, use the Azure portal to generate the redirect URI:
113+
Once you've generated a signature hash with _keytool_, use the Azure portal to generate the redirect URI:
116114

117-
1. Sign in to the <a href="https://portal.azure.com/" target="_blank">Azure portal</a> and select your Android app in **App registrations**.
118-
1. Select **Authentication** > **Add a platform** > **Android**.
115+
1. Sign in to the <a href="https://portal.azure.com/" target="_blank">Azure portal</a>.
116+
1. If you have access to multiple tenants, use the **Directories + subscriptions** filter :::image type="icon" source="/azure/active-directory/develop/media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you registered your application.
117+
1. Search for and select **Azure Active Directory**.
118+
1. Under **Manage**, select **App registrations**.
119+
1. Under **Manage**, select **App registrations**, then select your application.
120+
1. Under **Manage**, select **Authentication** > **Add a platform** > **Android**.
119121
1. In the **Configure your Android app** pane that opens, enter the **Signature hash** that you generated earlier and a **Package name**.
120122
1. Select the **Configure** button.
121123

@@ -151,29 +153,29 @@ If you get an `MsalClientException` with error code `"BROKER_BIND_FAILURE"`, the
151153
It might not be immediately clear that broker integration is working, but you can use the following steps to check:
152154

153155
1. On your Android device, complete a request using the broker.
154-
1. In the settings on your Android device, look for a newly created account corresponding to the account that you authenticated with. The account should be of type *Work account*.
156+
1. In the settings on your Android device, look for a newly created account corresponding to the account that you authenticated with. The account should be of type _Work account_.
155157

156158
You can remove the account from settings if you want to repeat the test.
157159

158160
## SSO through system browser
159161

160-
Android applications have the option to use the WebView, system browser, or Chrome Custom Tabs for authentication user experience. If the application is not using brokered authentication, it will need to use the system browser rather than the native webview in order to achieve SSO.
162+
Android applications have the option to use the WebView, system browser, or Chrome Custom Tabs for authentication user experience. If the application isn't using brokered authentication, it will need to use the system browser rather than the native webview in order to achieve SSO.
161163

162164
### Authorization agents
163165

164166
Choosing a specific strategy for authorization agents is optional and represents additional functionality apps can customize. Most apps will use the MSAL defaults (see [Understand the Android MSAL configuration file](msal-configuration.md) to see the various defaults).
165167

166-
MSAL supports authorization using a `WebView`, or the system browser. The image below shows how it looks using the `WebView`, or the system browser with CustomTabs or without CustomTabs:
168+
MSAL supports authorization using a `WebView`, or the system browser. The image below shows how it looks using the `WebView`, or the system browser with CustomTabs or without CustomTabs:
167169

168170
![MSAL login examples](./media/authorization-agents/sign-in-ui.jpg)
169171

170-
### Single sign-on implications
172+
### SSO implications
171173

172174
By default, applications integrated with MSAL use the system browser's Custom Tabs to authorize. Unlike WebViews, Custom Tabs share a cookie jar with the default system browser enabling fewer sign-ins with web or other native apps that have integrated with Custom Tabs.
173175

174176
If the application uses a `WebView` strategy without integrating Microsoft Authenticator or Company Portal support into their app, users won't have a single sign-on experience across the device or between native apps and web apps.
175177

176-
If the application uses MSAL with a broker like Microsoft Authenticator or Intune Company Portal, then users can have a SSO experience across applications if the they have an active sign-in with one of the apps.
178+
If the application uses MSAL with a broker like Microsoft Authenticator or Intune Company Portal, then users can have SSO experience across applications if they have an active sign-in with one of the apps.
177179

178180
### WebView
179181

@@ -183,7 +185,7 @@ To use the in-app WebView, put the following line in the app configuration JSON
183185
"authorization_user_agent" : "WEBVIEW"
184186
```
185187

186-
When using the in-app `WebView`, the user signs in directly to the app. The tokens are kept inside the sandbox of the app and aren't available outside the app's cookie jar. As a result, the user can't have a SSO experience across applications unless the apps integrate with the Authenticator or Company Portal.
188+
When using the in-app `WebView`, the user signs in directly to the app. The tokens are kept inside the sandbox of the app and aren't available outside the app's cookie jar. As a result, the user can't have SSO experience across applications unless the apps integrate with the Authenticator or Company Portal.
187189

188190
However, `WebView` does provide the capability to customize the look and feel for sign-in UI. See [Android WebViews](https://developer.android.com/reference/android/webkit/WebView) for more about how to do this customization.
189191

@@ -195,36 +197,36 @@ By default, MSAL uses the browser and a [custom tabs](https://developer.chrome.c
195197
"authorization_user_agent" : "BROWSER"
196198
```
197199

198-
Use this approach to provide a SSO experience through the device's browser. MSAL uses a shared cookie jar, which allows other native apps or web apps to achieve SSO on the device by using the persist session cookie set by MSAL.
200+
Use this approach to provide SSO experience through the device's browser. MSAL uses a shared cookie jar, which allows other native apps or web apps to achieve SSO on the device by using the persist session cookie set by MSAL.
199201

200202
### Browser selection heuristic
201203

202204
Because it's impossible for MSAL to specify the exact browser package to use on each of the broad array of Android phones, MSAL implements a browser selection heuristic that tries to provide the best cross-device SSO.
203205

204206
MSAL primarily retrieves the default browser from the package manager and checks if it is in a tested list of safe browsers. If not, MSAL falls back on using the Webview rather than launching another non-default browser from the safe list. The default browser will be chosen regardless of whether it supports custom tabs. If the browser supports Custom Tabs, MSAL will launch the Custom Tab. Custom Tabs have a look and feel closer to an in-app `WebView` and allow basic UI customization. See [Custom Tabs in Android](https://developer.chrome.com/multidevice/android/customtabs) to learn more.
205207

206-
If there are no browser packages on the device, MSAL uses the in-app `WebView`. If the device default setting isn't changed, the same browser should be launched for each sign in to ensure a SSO experience.
208+
If there are no browser packages on the device, MSAL uses the in-app `WebView`. If the device default setting isn't changed, the same browser should be launched for each sign-in to ensure SSO experience.
207209

208210
#### Tested Browsers
209211

210212
The following browsers have been tested to see if they correctly redirect to the `"redirect_uri"` specified in the configuration file:
211213

212-
| Device | Built-in Browser | Chrome | Opera | Microsoft Edge | UC Browser | Firefox |
213-
| -- |:-------------:| -----:|-----:|-----:|-----:|-----:|
214-
| Nexus 4 (API 17) | pass | pass |not applicable |not applicable |not applicable |not applicable |
215-
| Samsung S7 (API 25) | pass<sup>1</sup> | pass | pass | pass | fail |pass |
216-
| Huawei (API 26) |pass<sup>2</sup> | pass | fail | pass | pass |pass |
217-
| Vivo (API 26) |pass|pass|pass|pass|pass|fail|
218-
| Pixel 2 (API 26) |pass | pass | pass | pass | fail |pass |
219-
| Oppo | pass | not applicable<sup>3</sup>|not applicable |not applicable |not applicable | not applicable|
220-
| OnePlus (API 25) |pass | pass | pass | pass | fail |pass |
221-
| Nexus (API 28) |pass | pass | pass | pass | fail |pass |
222-
|MI | pass | pass | pass | pass | fail |pass |
214+
| Device | Built-in Browser | Chrome | Opera | Microsoft Edge | UC Browser | Firefox |
215+
| ------------------- | :--------------: | -------------------------: | -------------: | -------------: | -------------: | -------------: |
216+
| Nexus 4 (API 17) | pass | pass | not applicable | not applicable | not applicable | not applicable |
217+
| Samsung S7 (API 25) | pass<sup>1</sup> | pass | pass | pass | fail | pass |
218+
| Huawei (API 26) | pass<sup>2</sup> | pass | fail | pass | pass | pass |
219+
| Vivo (API 26) | pass | pass | pass | pass | pass | fail |
220+
| Pixel 2 (API 26) | pass | pass | pass | pass | fail | pass |
221+
| Oppo | pass | not applicable<sup>3</sup> | not applicable | not applicable | not applicable | not applicable |
222+
| OnePlus (API 25) | pass | pass | pass | pass | fail | pass |
223+
| Nexus (API 28) | pass | pass | pass | pass | fail | pass |
224+
| MI | pass | pass | pass | pass | fail | pass |
223225

224226
<sup>1</sup>Samsung's built-in browser is Samsung Internet.<br/>
225227
<sup>2</sup>Huawei's built-in browser is Huawei Browser.<br/>
226228
<sup>3</sup>The default browser can't be changed inside the Oppo device setting.
227229

228230
## Next steps
229231

230-
[Shared device mode for Android devices](msal-android-shared-devices.md) allows you to configure an Android device so that it can be easily shared by multiple employees.
232+
[Shared device mode for Android devices](msal-android-shared-devices.md) allows you to configure an Android device so that it can be easily shared by multiple employees.

0 commit comments

Comments
 (0)