You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/msal-ios-shared-devices.md
+94-43Lines changed: 94 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,20 +9,20 @@ ms.service: active-directory
9
9
ms.subservice: develop
10
10
ms.topic: conceptual
11
11
ms.workload: identity
12
-
ms.date: 03/31/2020
12
+
ms.date: 11/03/2022
13
13
ms.author: brandwe
14
14
ms.reviewer: brandwe
15
15
ms.custom: aaddev
16
16
---
17
17
18
18
# Shared device mode for iOS devices
19
19
20
-
>[!IMPORTANT]
20
+
>[!IMPORTANT]
21
21
> This feature [!INCLUDE [PREVIEW BOILERPLATE](../../../includes/active-directory-develop-preview.md)]
22
22
23
23
Frontline workers such as retail associates, flight crew members, and field service workers often use a shared mobile device to perform their work. These shared devices can present security risks if your users share their passwords or PINs, intentionally or not, to access customer and business data on the shared device.
24
24
25
-
Shared device mode allows you to configure an iOS 13 or higher device to be more easily and securely shared by employees. Employees can sign in and access customer information quickly. When they're finished with their shift or task, they can sign out of the device and it's immediately ready for use by the next employee.
25
+
Shared device mode allows you to configure an iOS 13 or higher device to be more easily and securely shared by employees. Employees can sign in and access customer information quickly. When they're finished with their shift or task, they can sign out of the device, and it's immediately ready for use by the next employee.
26
26
27
27
Shared device mode also provides Microsoft identity-backed management of the device.
28
28
@@ -32,13 +32,13 @@ This feature uses the [Microsoft Authenticator app](https://support.microsoft.co
32
32
33
33
To create a shared device mode app, developers and cloud device admins work together:
34
34
35
-
1.**Application developers** write a single-account app (multiple-account apps are not supported in shared device mode) and write code to handle things like shared device sign-out.
35
+
1.**Application developers** write a single-account app (multiple-account apps aren't supported in shared device mode) and write code to handle things like shared device sign-out.
36
36
37
37
1.**Device administrators** prepare the device to be shared by using a mobile device management (MDM) provider like Microsoft Intune to manage the devices in their organization. The MDM pushes the Microsoft Authenticator app to the devices and turns on "Shared Mode" for each device through a profile update to the device. This Shared Mode setting is what changes the behavior of the supported apps on the device. This configuration from the MDM provider sets the shared device mode for the device and enables the [Microsoft Enterprise SSO plug-in for Apple devices](apple-sso-plugin.md) which is required for shared device mode.
38
38
39
39
1.[**Required during Public Preview only**] A user with [Cloud Device Administrator](../roles/permissions-reference.md#cloud-device-administrator) role must then launch the [Microsoft Authenticator app](https://support.microsoft.com/account-billing/how-to-use-the-microsoft-authenticator-app-9783c865-0308-42fb-a519-8cf666fe0acc) and join their device to the organization.
40
40
41
-
To configure the membership of your organizational roles in the Azure portal: **Azure Active Directory** > **Roles and Administrators** > **Cloud Device Administrator**
41
+
To configure the membership of your organizational roles in the Azure portal: **Azure Active Directory** > **Roles and Administrators** > **Cloud Device Administrator**
42
42
43
43
The following sections help you update your application to support shared device mode.
44
44
@@ -51,40 +51,40 @@ Your device needs to be configured to support shared device mode. It must have i
51
51
52
52
1. In the Intune Configuration Portal, tell the device to enable the [Microsoft Enterprise SSO plug-in for Apple devices](apple-sso-plugin.md) with the following configuration:
For more information about configuring with Intune, see the [Intune configuration documentation](/intune/configuration/ios-device-features-settings).
73
73
74
74
1. Next, configure your MDM to push the Microsoft Authenticator app to your device through an MDM profile.
75
75
76
-
Set the following configuration options to turn on Shared Device mode:
76
+
Set the following configuration options to turn on Shared Device mode:
77
77
78
-
- Configuration 1:
79
-
- Key: sharedDeviceMode
80
-
- Type: Boolean
81
-
- Value: true
78
+
- Configuration 1:
79
+
- Key: sharedDeviceMode
80
+
- Type: Boolean
81
+
- Value: true
82
82
83
83
## Modify your iOS application to support shared device mode
84
84
85
85
Your users depend on you to ensure their data isn't leaked to another user. The following sections provide helpful signals to indicate to your application that a change has occurred and should be handled.
86
86
87
-
You are responsible for checking the state of the user on the device every time your app is used, and then clearing the previous user's data. This includes if it is reloaded from the background in multi-tasking.
87
+
You're responsible for checking the state of the user on the device every time your app is used, and then clearing the previous user's data. This includes if it's reloaded from the background in multi-tasking.
88
88
89
89
On a user change, you should ensure both the previous user's data is cleared and that any cached data being displayed in your application is removed. We highly recommend you and your company conduct a security review process after updating your app to support shared device mode.
### Get the signed-in user and determine if a user has changed on the device
130
130
131
-
Another important part of supporting shared device mode is determining the state of the user on the device and clearing application data if a user has changed or if there is no user at all on the device. You are responsible for ensuring data isn't leaked to another user.
131
+
Another important part of supporting shared device mode is determining the state of the user on the device and clearing application data if a user has changed or if there's no user at all on the device. You're responsible for ensuring data isn't leaked to another user.
132
132
133
133
You can use `getCurrentAccountWithParameters:completionBlock:` API to query the currently signed-in account on the device.
The following code removes the signed-in account and clears cached tokens from not only the app, but also from the device that's in shared device mode. It does not, however, clear the *data* from your application. You must clear the data from your application, as well as clear any cached data your application may be displaying to the user.
179
-
180
-
#### Clear browser state
181
-
182
-
> [!NOTE]
183
-
> The following step is required only during public preview.
184
-
185
-
In this public preview version, the [Microsoft Enterprise SSO plug-in for Apple devices](apple-sso-plugin.md) clears state only for applications. It does not clear state on the Safari browser. We recommend you manually clear browser session to ensure no traces of user state are left behind. You can use the optional `signoutFromBrowser` property shown below to clear any cookies. This will cause the browser to briefly launch on the device.
178
+
The following code removes the signed-in account and clears cached tokens from not only the app, but also from the device that's in shared device mode. It doesn't, however, clear the _data_ from your application. You must clear the data from your application, as well as clear any cached data your application may be displaying to the user.
186
179
187
180
#### Swift
188
181
189
182
```swift
190
183
let account =..../* account retrieved above */
191
184
192
185
let signoutParameters =MSALSignoutParameters(webviewParameters: self.webViewParamaters!)
193
-
signoutParameters.signoutFromBrowser=true//Only needed for Public Preview.
186
+
signoutParameters.signoutFromBrowser=true//To trigger a browser signout in Safari.
194
187
195
188
application.signout(with: account, signoutParameters: signoutParameters, completionBlock: {(success, error) in
196
-
197
189
iflet error = error {
190
+
198
191
// Signout failed
192
+
199
193
return
194
+
200
195
}
201
196
202
197
// Sign out completed successfully
198
+
203
199
})
204
200
```
205
201
@@ -209,22 +205,77 @@ application.signout(with: account, signoutParameters: signoutParameters, complet
The [Microsoft Enterprise SSO plug-in for Apple devices](apple-sso-plugin.md) clears state only for applications. It doesn't clear state on the Safari browser. You can use the optional signoutFromBrowser property shown in code snippets above to trigger a browser signout in Safari. This will cause the browser to briefly launch on the device.
231
+
232
+
### Receive broadcast to detect global sign out initiated from other applications
233
+
234
+
To receive the account change broadcast, you'll need to register a broadcast receiver. When an account change broadcast is received, immediately [get the signed in user and determine if a user has changed on the device](#get-the-signed-in-user-and-determine-if-a-user-has-changed-on-the-device). If a change is detected, initiate data cleanup for previously signed-in account. It's recommended to properly stop any operations and do data cleanup.
235
+
236
+
The following code snippet shows how you could register a broadcast receiver.
For iOS, your app will require a background permission to remain active in the background and listen to Darwin notifications. The background capability must be added to support a different background operation – your app may be subject to rejection from the Apple App Store if it has a background capability only to listen for Darwin notifications. If your app is already configured to complete background operations, you can add the listener as part of that operation. For more information about iOS background capabilities, see [Configuring background execution modes](https://developer.apple.com/documentation/xcode/configuring-background-execution-modes)
276
+
226
277
## Next steps
227
278
228
279
To see shared device mode in action, the following code sample on GitHub includes an example of running a frontline worker app on an iOS device in shared device mode:
229
280
230
-
[MSAL iOS Swift Microsoft Graph API Sample](https://github.com/Azure-Samples/ms-identity-mobile-apple-swift-objc)
281
+
[MSAL iOS Swift Microsoft Graph API Sample](https://github.com/Azure-Samples/ms-identity-mobile-apple-swift-objc)
Copy file name to clipboardExpand all lines: articles/active-directory/develop/tutorial-v2-shared-device-mode.md
+51-25Lines changed: 51 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.service: active-directory
9
9
ms.subservice: develop
10
10
ms.topic: tutorial
11
11
ms.workload: identity
12
-
ms.date: 1/15/2020
12
+
ms.date: 11/03/2022
13
13
ms.author: henrymbugua
14
14
ms.reviewer: brandwe
15
15
ms.custom: aaddev, identityplatformtop40
@@ -22,13 +22,14 @@ In this tutorial, Android developers and Azure Active Directory (Azure AD) tenan
22
22
In this tutorial:
23
23
24
24
> [!div class="checklist"]
25
-
> * Download a code sample
26
-
> * Enable and detect shared-device mode
27
-
> * Detect single or multiple account mode
28
-
> * Detect a user switch, and enable global sign-in and sign-out
29
-
> * Set up tenant and register the application in the Azure portal
30
-
> * Set up an Android device in shared-device mode
31
-
> * Run the sample app
25
+
>
26
+
> - Download a code sample
27
+
> - Enable and detect shared-device mode
28
+
> - Detect single or multiple account mode
29
+
> - Detect a user switch, and enable global sign-in and sign-out
30
+
> - Set up tenant and register the application in the Azure portal
31
+
> - Set up an Android device in shared-device mode
32
+
> - Run the sample app
32
33
33
34
## Prerequisites
34
35
@@ -64,21 +65,21 @@ Here's an example of the auth_config.json file included in the **app**>**main**>
64
65
65
66
```json
66
67
{
67
-
"client_id":"Client ID after app registration at https://aka.ms/MobileAppReg",
68
-
"authorization_user_agent":"DEFAULT",
69
-
"redirect_uri":"Redirect URI after app registration at https://aka.ms/MobileAppReg",
70
-
"account_mode":"SINGLE",
71
-
"broker_redirect_uri_registered": true,
72
-
"shared_device_mode_supported": true,
73
-
"authorities":[
74
-
{
75
-
"type":"AAD",
76
-
"audience":{
77
-
"type": "AzureADandPersonalMicrosoftAccount",
78
-
"tenant_id":"common"
79
-
}
80
-
}
81
-
]
68
+
"client_id":"Client ID after app registration at https://aka.ms/MobileAppReg",
69
+
"authorization_user_agent":"DEFAULT",
70
+
"redirect_uri":"Redirect URI after app registration at https://aka.ms/MobileAppReg",
71
+
"account_mode":"SINGLE",
72
+
"broker_redirect_uri_registered": true,
73
+
"shared_device_mode_supported": true,
74
+
"authorities":[
75
+
{
76
+
"type":"AAD",
77
+
"audience":{
78
+
"type": "AzureADandPersonalMicrosoftAccount",
79
+
"tenant_id":"common"
80
+
}
81
+
}
82
+
]
82
83
}
83
84
```
84
85
@@ -88,7 +89,7 @@ Shared-device mode allows you to configure Android devices to be shared by multi
88
89
89
90
Use `isSharedDevice()` to determine if an app is running on a device that is in shared-device mode. Your app could use this flag to determine if it should modify UX accordingly.
90
91
91
-
Here's a code snippet that shows how you could use `isSharedDevice()`. It's from the `SingleAccountModeFragment` class in the sample app:
92
+
Here's a code snippet that shows how you could use `isSharedDevice()`. It's from the `SingleAccountModeFragment` class in the sample app:
### Receive broadcast to detect global sign out initiated from other applications
209
+
210
+
To receive the account change broadcast, you'll need to register a broadcast receiver. It’s recommended to register your broadcast receiver via the [Context-registered receivers](https://developer.android.com/guide/components/broadcasts#context-registered-receivers).
211
+
212
+
When an account change broadcast is received, immediately [get the signed in user and determine if a user has changed on the device](#get-the-signed-in-user-and-determine-if-a-user-has-changed-on-the-device). If a change is detected, initiate data cleanup for previously signed-in account. It is recommended to properly stop any operations and do data cleanup.
213
+
214
+
The following code snippet shows how you could register a broadcast receiver.
215
+
216
+
```java
217
+
private static final String CURRENT_ACCOUNT_CHANGED_BROADCAST_IDENTIFIER = "com.microsoft.identity.client.sharedmode.CURRENT_ACCOUNT_CHANGED";
Any sign-ins and sign-outs on the device will be global, meaning they apply to all apps that are integrated with MSAL and Microsoft Authenticator on the device. You can now deploy applications to the device that use shared-device mode features.
286
+
Any sign-ins and sign-outs on the device will be global, meaning they apply to all apps that are integrated with MSAL and MicrosoftAuthenticator on the device. You can now deploy applications to the device that use shared-device mode features.
0 commit comments