Skip to content

Commit 5914292

Browse files
authored
Merge pull request #219432 from henrymbuguakiarie/msid-content-health-single-sign-on-macos-ios
[msid][content-health] single sign on macos ios (ADO-2177156)
2 parents dcf6050 + a89edc7 commit 5914292

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

articles/active-directory/develop/single-sign-on-macos-ios.md

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Configure SSO on macOS and iOS
2+
title: Configure SSO on macOS and iOS
33
description: Learn how to configure single sign on (SSO) on macOS and iOS.
44
services: active-directory
55
author: henrymbuguakiarie
@@ -9,35 +9,33 @@ ms.service: active-directory
99
ms.subservice: develop
1010
ms.topic: conceptual
1111
ms.workload: identity
12-
ms.date: 02/03/2020
12+
ms.date: 11/23/2022
1313
ms.author: henrymbugua
14-
ms.reviewer:
15-
ms.custom: aaddev
14+
ms.reviewer:
15+
ms.custom: aaddev, engagement-fy23
1616
---
1717

1818
# Configure SSO on macOS and iOS
1919

20-
The Microsoft Authentication Library (MSAL) for macOS and iOS supports Single Sign-on (SSO) between macOS/iOS apps and browsers. This article covers the following SSO scenarios:
20+
The Microsoft Authentication Library (MSAL) for macOS and iOS supports single sign-on (SSO) between macOS/iOS apps and browsers. This article covers the following SSO scenarios:
2121

2222
- [Silent SSO between multiple apps](#silent-sso-between-apps)
2323

24-
This type of SSO works between multiple apps distributed by the same Apple Developer. It provides silent SSO (that is, the user isn't prompted for credentials) by reading refresh tokens written by other apps from the keychain, and exchanging them for access tokens silently.
24+
This type of SSO works between multiple apps distributed by the same Apple Developer. It provides silent SSO (that is, the user isn't prompted for credentials) by reading refresh tokens written by other apps from the keychain, and exchanging them for access tokens silently.
2525

2626
- [SSO through Authentication broker](#sso-through-authentication-broker-on-ios)
2727

28-
> [!IMPORTANT]
29-
> This flow is not available on macOS.
28+
The SSO through authentication broker isn't available on macOS.
3029

31-
Microsoft provides apps, called brokers, that enable SSO between applications from different vendors as long as the mobile device is registered with Azure Active Directory (AAD). This type of SSO requires a broker application be installed on the user's device.
30+
Microsoft provides apps called brokers, that enable SSO between applications from different vendors as long as the mobile device is registered with Azure Active Directory (Azure AD). This type of SSO requires a broker application be installed on the user's device.
3231

3332
- **SSO between MSAL and Safari**
3433

3534
SSO is achieved through the [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession?language=objc) class. It uses existing sign-in state from other apps and the Safari browser. It's not limited to apps distributed by the same Apple Developer, but it requires some user interaction.
3635

3736
If you use the default web view in your app to sign in users, you'll get automatic SSO between MSAL-based applications and Safari. To learn more about the web views that MSAL supports, visit [Customize browsers and WebViews](customize-webviews.md).
3837

39-
> [!IMPORTANT]
40-
> This type of SSO is currently not available on macOS. MSAL on macOS only supports WKWebView which doesn't have SSO support with Safari.
38+
This type of SSO is currently not available on macOS. MSAL on macOS only supports WKWebView which doesn't have SSO support with Safari.
4139

4240
- **Silent SSO between ADAL and MSAL macOS/iOS apps**
4341

@@ -64,10 +62,9 @@ The way the Microsoft identity platform tells apps that use the same Application
6462

6563
App1 Redirect URI: `msauth.com.contoso.mytestapp1://auth`
6664
App2 Redirect URI: `msauth.com.contoso.mytestapp2://auth`
67-
App3 Redirect URI: `msauth.com.contoso.mytestapp3://auth`
65+
App3 Redirect URI: `msauth.com.contoso.mytestapp3://auth`
6866

69-
> [!IMPORTANT]
70-
> The format of redirect URIs must be compatible with the format MSAL supports, which is documented in [MSAL Redirect URI format requirements](redirect-uris-ios.md#msal-redirect-uri-format-requirements).
67+
The format of redirect URIs must be compatible with the format MSAL supports, which is documented in [MSAL Redirect URI format requirements](redirect-uris-ios.md#msal-redirect-uri-format-requirements).
7168

7269
### Setup keychain sharing between applications
7370

@@ -92,8 +89,9 @@ When you have the entitlements set up correctly, you'll see a `entitlements.plis
9289
#### Add a new keychain group
9390

9491
Add a new keychain group to your project **Capabilities**. The keychain group should be:
95-
* `com.microsoft.adalcache` on iOS
96-
* `com.microsoft.identity.universalstorage` on macOS.
92+
93+
- `com.microsoft.adalcache` on iOS
94+
- `com.microsoft.identity.universalstorage` on macOS.
9795

9896
![keychain example](media/single-sign-on-macos-ios/keychain-example.png)
9997

@@ -109,7 +107,7 @@ Objective-C:
109107
NSError *error = nil;
110108
MSALPublicClientApplicationConfig *configuration = [[MSALPublicClientApplicationConfig alloc] initWithClientId:@"<my-client-id>"];
111109
configuration.cacheConfig.keychainSharingGroup = @"my.keychain.group";
112-
110+
113111
MSALPublicClientApplication *application = [[MSALPublicClientApplication alloc] initWithConfiguration:configuration error:&error];
114112
```
115113
@@ -136,48 +134,48 @@ That's it! The Microsoft identity SDK will now share credentials across all your
136134

137135
## SSO through Authentication broker on iOS
138136

139-
MSAL provides support for brokered authentication with Microsoft Authenticator. Microsoft Authenticator provides SSO for AAD registered devices, and also helps your application follow Conditional Access policies.
137+
MSAL provides support for brokered authentication with Microsoft Authenticator. Microsoft Authenticator provides SSO for Azure AD registered devices, and also helps your application follow Conditional Access policies.
140138

141139
The following steps are how you enable SSO using an authentication broker for your app:
142140

143141
1. Register a broker compatible Redirect URI format for the application in your app's Info.plist. The broker compatible Redirect URI format is `msauth.<app.bundle.id>://auth`. Replace `<app.bundle.id>`` with your application's bundle ID. For example:
144142

145-
```xml
146-
<key>CFBundleURLSchemes</key>
147-
<array>
148-
<string>msauth.<app.bundle.id></string>
149-
</array>
150-
```
143+
```xml
144+
<key>CFBundleURLSchemes</key>
145+
<array>
146+
<string>msauth.<app.bundle.id></string>
147+
</array>
148+
```
151149

152150
1. Add following schemes to your app's Info.plist under `LSApplicationQueriesSchemes`:
153151

154-
```xml
155-
<key>LSApplicationQueriesSchemes</key>
156-
<array>
157-
<string>msauthv2</string>
158-
<string>msauthv3</string>
159-
</array>
160-
```
152+
```xml
153+
<key>LSApplicationQueriesSchemes</key>
154+
<array>
155+
<string>msauthv2</string>
156+
<string>msauthv3</string>
157+
</array>
158+
```
161159

162160
1. Add the following to your `AppDelegate.m` file to handle callbacks:
163161

164-
Objective-C:
165-
166-
```objc
167-
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
168-
{
169-
return [MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
170-
}
171-
```
172-
173-
Swift:
174-
175-
```swift
176-
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
177-
return MSALPublicClientApplication.handleMSALResponse(url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String)
178-
}
179-
```
180-
162+
Objective-C:
163+
164+
```objc
165+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
166+
{
167+
return [MSALPublicClientApplication handleMSALResponse:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
168+
}
169+
```
170+
171+
Swift:
172+
173+
```swift
174+
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
175+
return MSALPublicClientApplication.handleMSALResponse(url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String)
176+
}
177+
```
178+
181179
**If you are using Xcode 11**, you should place MSAL callback into the `SceneDelegate` file instead.
182180
If you support both UISceneDelegate and UIApplicationDelegate for compatibility with older iOS, MSAL callback would need to be placed into both files.
183181

@@ -189,7 +187,7 @@ Objective-C:
189187
UIOpenURLContext *context = URLContexts.anyObject;
190188
NSURL *url = context.URL;
191189
NSString *sourceApplication = context.options.sourceApplication;
192-
190+
193191
[MSALPublicClientApplication handleMSALResponse:url sourceApplication:sourceApplication];
194192
}
195193
```
@@ -198,14 +196,14 @@ Swift:
198196
199197
```swift
200198
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
201-
199+
202200
guard let urlContext = URLContexts.first else {
203201
return
204202
}
205-
203+
206204
let url = urlContext.url
207205
let sourceApp = urlContext.options.sourceApplication
208-
206+
209207
MSALPublicClientApplication.handleMSALResponse(url, sourceApplication: sourceApp)
210208
}
211209
```

0 commit comments

Comments
 (0)