Skip to content

Commit 8cf70ff

Browse files
authored
Merge pull request #197401 from mmacy/docs-editor/msal-js-sso-1651863844
[msid][issue] Login hint description inconsistent (GH-90189)
2 parents fa185fb + b2b677f commit 8cf70ff

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

articles/active-directory/develop/msal-js-sso.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ ms.custom: aaddev, has-adal-ref
1919

2020
# Single sign-on with MSAL.js
2121

22-
Single Sign-On (SSO) enables users to enter their credentials once to sign in and establish a session, which can be reused across multiple applications without requiring to authenticate again. The session provides a seamless experience to the user and reduces the repeated prompts for credentials.
22+
Single sign-on (SSO) provides a more seamless experience by reducing the number of times your users are asked for their credentials. Users enter their credentials once, and the established session can be reused by other applications on the device without further prompting.
2323

24-
Azure Active Directory (Azure AD) provides SSO capabilities to applications by setting a session cookie when the user authenticates the first time. The MSAL.js library allows applications to apply a session cookie in a few ways.
24+
Azure Active Directory (Azure AD) enables SSO by setting a session cookie when a user first authenticates. MSAL.js allows use of the session cookie for SSO between the browser tabs opened for one or several applications.
2525

2626
## SSO between browser tabs
2727

28-
When your application is open in multiple tabs and you first sign in the user on one tab, the user is also signed in on the other tabs without being prompted. MSAL.js caches the ID token for the user in the browser `localStorage` and will sign the user in to the application on the other open tabs.
28+
When a user has your application open in several tabs and signs in on one of them, they're signed into the same app open on the other tabs without being prompted. MSAL.js caches the ID token for the user in the browser `localStorage` and will sign the user in to the application on the other open tabs.
2929

3030
By default, MSAL.js uses `sessionStorage`, which doesn't allow the session to be shared between tabs. To get SSO between tabs, make sure to set the `cacheLocation` in MSAL.js to `localStorage` as shown below.
3131

3232
```javascript
33-
3433
const config = {
3534
auth: {
3635
clientId: "abcd-ef12-gh34-ikkl-ashdjhlhsdg",
@@ -55,17 +54,21 @@ When applications are hosted on the same domain, the user can sign into an app o
5554

5655
When applications are hosted on different domains, the tokens cached on domain A cannot be accessed by MSAL.js in domain B.
5756

58-
When a user is signed in on domain A navigate to an application on domain B, the user will be redirected or prompted with the sign-in page. Since Azure AD still has the user session cookie, it will sign in the user and no prompt for credentials.
57+
When a user signed in on domain A navigates to an application on domain B, they're typically redirected or prompted to sign in. Because Azure AD still has the user's session cookie, it signs in the user without prompting for credentials.
58+
59+
If the user has multiple user accounts in a session with Azure AD, the user is prompted to pick an account to sign in with.
5960

60-
If the user has multiple user accounts in session with Azure AD, the user will be prompted to pick the relevant account to sign in with.
61+
### Automatic account selection
6162

62-
### Automatically select account on Azure AD
63+
When a user is signed in concurrently to multiple Azure AD accounts on the same device, you might find you have the need to bypass the account selection prompt.
6364

64-
In certain cases, the application has access to the user's authentication context and there's a need to bypass the Azure AD account selection prompt when multiple accounts are signed in. Bypassing the Azure AD account selection prompt can be done in a few different ways:
65+
**Using a session ID**
6566

66-
**Using Session ID**
67+
Use the session ID (SID) in silent authentication requests you make with `acquireTokenSilent` in MSAL.js.
6768

68-
Session ID (SID) is an [optional claim](active-directory-optional-claims.md) that can be configured in the ID tokens. A claim allows the application to identify the user’s Azure AD session independent of the user’s account name or username. You can pass the SID in the request parameters to the `acquireTokenSilent` call. The `acquireTokenSilent` in the request parameters allow Azure AD to bypass the account selection. SID is bound to the session cookie and won't cross browser contexts.
69+
To use a SID, add `sid` as an [optional claim](active-directory-optional-claims.md) to your app's ID tokens. The `sid` claim allows an application to identify a user's Azure AD session independent of their account name or username. To learn how to add optional claims like `sid`, see [Provide optional claims to your app](active-directory-optional-claims.md).
70+
71+
The SID is bound to the session cookie and won't cross browser contexts. You can use the SID only with `acquireTokenSilent`.
6972

7073
```javascript
7174
var request = {
@@ -82,11 +85,9 @@ var request = {
8285
});
8386
```
8487

85-
SID can be used only with silent authentication requests made by `acquireTokenSilent` call in MSAL.js. To find the steps to configure optional claims in your application manifest, see [Provide optional claims to your app](active-directory-optional-claims.md).
86-
87-
**Using Login Hint**
88+
**Using a login hint**
8889

89-
If you don't have SID claim configured or need to bypass the account selection prompt in interactive authentication calls, you can do so by providing a `login_hint` in the request parameters and optionally a `domain_hint` as `extraQueryParameters` in the MSAL.js interactive methods (`loginPopup`, `loginRedirect`, `acquireTokenPopup`, and `acquireTokenRedirect`). For example:
90+
To bypass the account selection prompt typically shown during interactive authentication requests (or for silent requests when you haven't configured the `sid` optional claim), provide a `loginHint`. In multi-tenant applications, also include a `domain_hint`.
9091

9192
```javascript
9293
var request = {
@@ -98,13 +99,13 @@ var request = {
9899
msalInstance.loginRedirect(request);
99100
```
100101

101-
To get the values for login_hint and domain_hint by reading the claims returned in the ID token for the user.
102+
Get the values for `loginHint` and `domain_hint` from the user's **ID token**:
102103

103-
- **loginHint** should be set to the `preferred_username` claim in the ID token.
104+
- `loginHint`: Use the ID token's `preferred_username` claim value.
104105

105-
- **domain_hint** is only required to be passed when using the /common authority. The domain hint is determined by tenant ID(tid). If the `tid` claim in the ID token is `9188040d-6c67-4c5b-b112-36a304b66dad` it's consumers. Otherwise, it's organizations.
106+
- `domain_hint`: Use the ID token's `tid` claim value. Required in requests made by multi-tenant applications that use the */common* authority. Optional for other applications.
106107

107-
For more information about **login_hint** and **domain_hint**, see [auth code grant](v2-oauth2-auth-code-flow.md).
108+
For more information about login hint and domain hint, see [Microsoft identity platform and OAuth 2.0 authorization code flow](v2-oauth2-auth-code-flow.md).
108109

109110
## SSO without MSAL.js login
110111

0 commit comments

Comments
 (0)