Skip to content

Commit d3ee23c

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/azure-docs-pr into labssecurerdgateway
2 parents 814bce4 + c736da2 commit d3ee23c

File tree

362 files changed

+6368
-3537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

362 files changed

+6368
-3537
lines changed

.openpublishing.redirection.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3430,6 +3430,11 @@
34303430
"redirect_url": "/azure/azure-resource-manager/resource-group-authenticate-service-principal",
34313431
"redirect_document_id": false
34323432
},
3433+
{
3434+
"source_path": "articles/active-directory/develop/msal-testing.md",
3435+
"redirect_url": "/azure/active-directory/develop/msal-overview",
3436+
"redirect_document_id": true
3437+
},
34333438
{
34343439
"source_path": "articles/azure-resource-manager/resource-group-authenticate-service-principal.md",
34353440
"redirect_url": "/azure/active-directory/develop/howto-authenticate-service-principal-powershell",
@@ -39552,6 +39557,11 @@
3955239557
"source_path": "articles/active-directory-domain-services/active-directory-ds-troubleshooting.md",
3955339558
"redirect_url": "/azure/active-directory-domain-services/troubleshoot",
3955439559
"redirect_document_id": false
39555-
}
39560+
},
39561+
{
39562+
"source_path": "articles/backup/backup-azure-upgrade-backup-to-recovery-services.md",
39563+
"redirect_url": "/azure/backup/backup-create-rs-vault",
39564+
"redirect_document_id": true
39565+
}
3955639566
]
3955739567
}

articles/active-directory/develop/TOC.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@
228228
- name: Initialize applications (JS)
229229
href: msal-js-initializing-client-applications.md
230230
- name: Handle errors and exceptions
231-
href: msal-handling-exceptions.md
232-
- name: Test MSAL applications
233-
href: msal-testing.md
231+
href: msal-handling-exceptions.md
234232
- name: Logging
235233
href: msal-logging.md
236234
- name: Single sign-on (JS)
@@ -366,6 +364,12 @@
366364
href: msal-net-user-gets-consent-for-multiple-resources.md
367365
- name: Provide your own HttpClient
368366
href: msal-net-provide-httpclient.md
367+
- name: MSAL.js
368+
items:
369+
- name: Avoid page reloads
370+
href: msal-js-avoid-page-reloads.md
371+
- name: Pass custom state in authentication requests
372+
href: msal-js-pass-custom-state-authentication-request.md
369373
- name: Work with Visual Studio
370374
items:
371375
- name: Use the Active Directory connected service

articles/active-directory/develop/active-directory-v2-protocols.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.workload: identity
1414
ms.tgt_pltfrm: na
1515
ms.devlang: na
1616
ms.topic: article
17-
ms.date: 04/11/2019
17+
ms.date: 05/30/2019
1818
ms.author: ryanwi
1919
ms.reviewer: hirsin
2020
ms.custom: aaddev
@@ -44,7 +44,7 @@ In nearly all OAuth 2.0 and OpenID Connect flows, there are four parties involve
4444
Every app that wants to accept both personal and work or school accounts must be registered through the **App registrations** experience in the [Azure portal](https://aka.ms/appregistrations) before it can sign these users in using OAuth 2.0 or OpenID Connect. The app registration process will collect and assign a few values to your app:
4545

4646
* An **Application ID** that uniquely identifies your app
47-
* A **Redirect URI** or **Package Identifier** that can be used to direct responses back to your app
47+
* A **Redirect URI** (optional) that can be used to direct responses back to your app
4848
* A few other scenario-specific values.
4949

5050
For more details, learn how to [register an app](quickstart-register-app.md).

articles/active-directory/develop/msal-client-application-configuration.md

Lines changed: 54 additions & 55 deletions
Large diffs are not rendered by default.

articles/active-directory/develop/msal-client-applications.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@ ms.date: 04/25/2019
1717
ms.author: ryanwi
1818
ms.reviewer: saeeda
1919
ms.custom: aaddev
20-
#Customer intent: As an application developer, I want to learn about the types of client application so I can decide if this platform meets my application development needs and requirements.
20+
#Customer intent: As an application developer, I want to learn about the types of client apps so I can decide if this platform meets my app development requirements.
2121
ms.collection: M365-identity-device-management
2222
---
2323

2424
# Public client and confidential client applications
25-
Microsoft Authentication Library (MSAL) defines two types of clients: public clients and confidential clients. The two client types are distinguished by their ability to authenticate securely with the authorization server and maintain the confidentiality of their client credentials. In contrast, Azure AD Authentication Library (ADAL) has the concept of authentication context (which is a connection to Azure AD).
25+
Microsoft Authentication Library (MSAL) defines two types of clients: public clients and confidential clients. The two client types are distinguished by their ability to authenticate securely with the authorization server and maintain the confidentiality of their client credentials. In contrast, Azure AD Authentication Library (ADAL) uses what's called *authentication context* (which is a connection to Azure AD).
2626

27-
- **Confidential client applications** are applications, which run on servers (Web Apps, Web API, or even service/daemon applications). They are considered difficult to access, and therefore capable of keeping an application secret. Confidential clients are able to hold configuration time secrets. Each instance of the client has a distinct configuration (including clientId and secret). These values are difficult for end users to extract. A web app is the most common confidential client. The client ID is exposed through the web browser, but the secret is passed only in the back channel and never directly exposed.
27+
- **Confidential client applications** are apps that run on servers (web apps, Web API apps, or even service/daemon apps). They're considered difficult to access, and for that reason capable of keeping an application secret. Confidential clients can hold configuration-time secrets. Each instance of the client has a distinct configuration (including client ID and client secret). These values are difficult for end users to extract. A web app is the most common confidential client. The client ID is exposed through the web browser, but the secret is passed only in the back channel and never directly exposed.
2828

2929
Confidential client apps: <BR>
3030
![Web app](media/msal-client-applications/web-app.png) ![Web API](media/msal-client-applications/web-api.png) ![Daemon/service](media/msal-client-applications/daemon-service.png)
3131

32-
- **Public client applications** are applications, which run on devices or desktop machines or in a web browser. They are not trusted to safely keep application secrets, and therefore only access Web APIs on behalf of the user (they only support public client flows). Public clients are unable to hold configuration time secrets, and as a result have no client secret.
32+
- **Public client applications** are apps that run on devices or desktop computers or in a web browser. They're not trusted to safely keep application secrets, so they only access Web APIs on behalf of the user. (They support only public client flows.) Public clients can't hold configuration-time secrets, so they don't have client secrets.
3333

34-
Public client applications: <BR>
34+
Public client apps: <BR>
3535
![Desktop app](media/msal-client-applications/desktop-app.png) ![Browserless API](media/msal-client-applications/browserless-app.png) ![Mobile app](media/msal-client-applications/mobile-app.png)
3636

3737
> [!NOTE]
38-
> In MSAL.js, there is no separation of public and confidential client apps. MSAL.js represents client apps as user-agent-based apps, a public client in which the client code is executed in a user-agent such as a web browser. These clients do not store secrets, since the browser context is openly accessible.
38+
> In MSAL.js, there is no separation of public and confidential client apps. MSAL.js represents client apps as user agent-based apps, public clients in which the client code is executed in a user agent like a web browser. These clients don't store secrets because the browser context is openly accessible.
3939
4040
## Comparing the client types
41-
There are some commonalities and differences between public client and confidential client applications:
41+
Here are some similarities and differences between public client and confidential client apps:
4242

43-
- Both kinds of applications maintain a user token cache and can acquire a token silently (in cases where the token is already in the token cache). Confidential client applications also have an app token cache for tokens, which are for the app itself.
44-
- Both manage user accounts and can get the accounts from the user token cache, get an account from its identifier, or remove an account.
45-
- Public client applications have four ways of acquiring a token (four authentication flows), whereas confidential client applications have three (and one method to compute the URL of the identity provider authorize endpoint). For more information, see Scenarios and Acquiring tokens.
43+
- Both kinds of app maintain a user token cache and can acquire a token silently (when the token is already in the token cache). Confidential client apps also have an app token cache for tokens that are for the app itself.
44+
- Both types of app manage user accounts and can get an account from the user token cache, get an account from its identifier, or remove an account.
45+
- Public client apps have four ways to acquire a token (four authentication flows). Confidential client apps have three ways to acquire a token (and one way to compute the URL of the identity provider authorize endpoint). For more information, see [Acquiring tokens](msal-acquire-cache-tokens.md).
4646

47-
If you used ADAL in the past, you might notice that, contrary to ADAL's authentication context, in MSAL the client ID (also named application ID or app ID) is passed once at the construction of the application, and no longer needs to be repeated when acquiring a token. This is the case both for public and confidential client applications. Constructors of confidential client applications are also passed client credentials: the secret they share with the identity provider.
47+
If you've used ADAL, you might notice that, unlike ADAL's authentication context, in MSAL the client ID (also called the *application ID* or *app ID*) is passed once at the construction of the application. It doesn't need to be passed again when the app acquires a token. This is true for both for public and confidential client apps. Constructors of confidential client apps are also passed client credentials: the secret they share with the identity provider.
4848

4949
## Next steps
5050
Learn about:
5151
- [Client application configuration options](msal-client-application-configuration.md)
52-
- [Instantiating client applications using MSAL.NET](msal-net-initializing-client-applications.md).
53-
- [Instantiating client applications using MSAL.js](msal-js-initializing-client-applications.md).
52+
- [Instantiating client applications by using MSAL.NET](msal-net-initializing-client-applications.md)
53+
- [Instantiating client applications by using MSAL.js](msal-js-initializing-client-applications.md)
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: Avoid page reloads (Microsoft Authentication Library for JavaScript) | Azure
3+
description: Learn how to avoid page reloads when acquiring and renewing tokens silently using the Microsoft Authentication Library for JavaScript (MSAL.js).
4+
services: active-directory
5+
documentationcenter: dev-center-name
6+
author: rwike77
7+
manager: CelesteDG
8+
editor: ''
9+
10+
ms.service: active-directory
11+
ms.subservice: develop
12+
ms.devlang: na
13+
ms.topic: conceptual
14+
ms.tgt_pltfrm: na
15+
ms.workload: identity
16+
ms.date: 05/29/2019
17+
ms.author: nacanuma
18+
ms.reviewer: saeeda
19+
ms.custom: aaddev
20+
#Customer intent: As an application developer, I want to learn about avoiding page reloads so I can create more robust applications.
21+
ms.collection: M365-identity-device-management
22+
---
23+
24+
# Avoid page reloads when acquiring and renewing tokens silently using MSAL.js
25+
Microsoft Authentication Library for JavaScript (MSAL.js) uses hidden `iframe` elements to acquire and renew tokens silently in the background. Azure AD returns the token back to the registered redirect_uri specified in the token request(by default this is the app's root page). Since the response is a 302, it results in the HTML corresponding to the `redirect_uri` getting loaded in the `iframe`. Usually the app's `redirect_uri` is the root page and this causes it to reload.
26+
27+
In other cases, if navigating to the app's root page requires authentication, it might lead to nested `iframe` elements or `X-Frame-Options: deny` error.
28+
29+
Since MSAL.js cannot dismiss the 302 issued by Azure AD and is required to process the returned token, it cannot prevent the `redirect_uri` from getting loaded in the `iframe`.
30+
31+
To avoid the entire app reloading again or other errors caused due to this, please follow these workarounds.
32+
33+
## Specify different HTML for the iframe
34+
35+
Set the `redirect_uri` property on config to a simple page, that does not require authentication. You have to make sure that it matches with the `redirect_uri` registered in Azure portal. This will not affect user's login experience as MSAL saves the start page when user begins the login process and redirects back to the exact location after login is completed.
36+
37+
## Initialization in your main app file
38+
39+
If your app is structured such that there is one central Javascript file that defines the app's initialization, routing, and other stuff, you can conditionally load your app modules based on whether the app is loading in an `iframe` or not. For example:
40+
41+
In AngularJS: app.js
42+
43+
```javascript
44+
// Check that the window is an iframe and not popup
45+
if (window !== window.parent && !window.opener) {
46+
angular.module('todoApp', ['ui.router', 'MsalAngular'])
47+
.config(['$httpProvider', 'msalAuthenticationServiceProvider','$locationProvider', function ($httpProvider, msalProvider,$locationProvider) {
48+
msalProvider.init(
49+
// msal configuration
50+
);
51+
52+
$locationProvider.html5Mode(false).hashPrefix('');
53+
}]);
54+
}
55+
else {
56+
angular.module('todoApp', ['ui.router', 'MsalAngular'])
57+
.config(['$stateProvider', '$httpProvider', 'msalAuthenticationServiceProvider', '$locationProvider', function ($stateProvider, $httpProvider, msalProvider, $locationProvider) {
58+
$stateProvider.state("Home", {
59+
url: '/Home',
60+
controller: "homeCtrl",
61+
templateUrl: "/App/Views/Home.html",
62+
}).state("TodoList", {
63+
url: '/TodoList',
64+
controller: "todoListCtrl",
65+
templateUrl: "/App/Views/TodoList.html",
66+
requireLogin: true
67+
})
68+
69+
$locationProvider.html5Mode(false).hashPrefix('');
70+
71+
msalProvider.init(
72+
// msal configuration
73+
);
74+
}]);
75+
}
76+
```
77+
78+
In Angular: app.module.ts
79+
80+
```javascript
81+
// Imports...
82+
@NgModule({
83+
declarations: [
84+
AppComponent,
85+
MsalComponent,
86+
MainMenuComponent,
87+
AccountMenuComponent,
88+
OsNavComponent
89+
],
90+
imports: [
91+
BrowserModule,
92+
AppRoutingModule,
93+
HttpClientModule,
94+
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
95+
MsalModule.forRoot(environment.MsalConfig),
96+
SuiModule,
97+
PagesModule
98+
],
99+
providers: [
100+
HttpServiceHelper,
101+
{provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: true},
102+
AuthService
103+
],
104+
entryComponents: [
105+
AppComponent,
106+
MsalComponent
107+
]
108+
})
109+
export class AppModule {
110+
constructor() {
111+
console.log('APP Module Constructor!');
112+
}
113+
114+
ngDoBootstrap(ref: ApplicationRef) {
115+
if (window !== window.parent && !window.opener)
116+
{
117+
console.log("Bootstrap: MSAL");
118+
ref.bootstrap(MsalComponent);
119+
}
120+
else
121+
{
122+
//this.router.resetConfig(RouterModule);
123+
console.log("Bootstrap: App");
124+
ref.bootstrap(AppComponent);
125+
}
126+
}
127+
}
128+
```
129+
130+
MsalComponent:
131+
132+
```javascript
133+
import { Component} from '@angular/core';
134+
import { MsalService } from '@azure/msal-angular';
135+
136+
// This component is used only to avoid Angular reload
137+
// when doing acquireTokenSilent()
138+
139+
@Component({
140+
selector: 'app-root',
141+
template: '',
142+
})
143+
export class MsalComponent {
144+
constructor(private Msal: MsalService) {
145+
}
146+
}
147+
```
148+
149+
## Next steps
150+
Learn more about [building a single-page application (SPA)](scenario-spa-overview.md) using MSAL.js.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Pass custom state in authentication requests (Microsoft Authentication Library for JavaScript) | Azure
3+
description: Learn how to pass a custom state parameter value in authentication request using the Microsoft Authentication Library for JavaScript (MSAL.js).
4+
services: active-directory
5+
documentationcenter: dev-center-name
6+
author: rwike77
7+
manager: CelesteDG
8+
editor: ''
9+
10+
ms.service: active-directory
11+
ms.subservice: develop
12+
ms.devlang: na
13+
ms.topic: conceptual
14+
ms.tgt_pltfrm: na
15+
ms.workload: identity
16+
ms.date: 05/29/2019
17+
ms.author: nacanuma
18+
ms.reviewer: saeeda
19+
ms.custom: aaddev
20+
#Customer intent: As an application developer, I want to learn about passing custom state in authentication requests so I can create more robust applications.
21+
ms.collection: M365-identity-device-management
22+
---
23+
24+
# Pass custom state in authentication requests using MSAL.js
25+
The *state* parameter, as defined by OAuth 2.0, is included in an authentication request and is also returned in the token response to prevent cross-site request forgery attacks. By default, Microsoft Authentication Library for JavaScript (MSAL.js) passes a randomly generated unique *state* parameter value in the authentication requests.
26+
27+
The state parameter can also be used to encode information of the app's state before redirect. You can pass the user's state in the app, such as the page or view they were on, as input to this parameter. The MSAL.js library allows you to pass your custom state as state parameter in the `Request` object:
28+
29+
```javascript
30+
// Request type
31+
export type AuthenticationParameters = {
32+
scopes?: Array<string>;
33+
extraScopesToConsent?: Array<string>;
34+
prompt?: string;
35+
extraQueryParameters?: QPDict;
36+
claimsRequest?: string;
37+
authority?: string;
38+
state?: string;
39+
correlationId?: string;
40+
account?: Account;
41+
sid?: string;
42+
loginHint?: string;
43+
};
44+
```
45+
46+
For example:
47+
48+
```javascript
49+
let loginRequest = {
50+
scopes: ["user.read", "user.write"],
51+
state: “page_url”
52+
}
53+
54+
myMSALObj.loginPopup(loginRequest);
55+
```
56+
57+
The passed in state is appended to the unique GUID set by MSAL.js when sending the request. When the response is returned, MSAL.js checks for a state match and then returns the custom passed in state in the `Response` object as `accountState`.
58+
59+
```javascript
60+
export type AuthResponse = {
61+
uniqueId: string;
62+
tenantId: string;
63+
tokenType: string;
64+
idToken: IdToken;
65+
accessToken: string;
66+
scopes: Array<string>;
67+
expiresOn: Date;
68+
account: Account;
69+
accountState: string;
70+
};
71+
```
72+
73+
To learn more, read about [building a single-page application (SPA)](scenario-spa-overview.md) using MSAL.js.

0 commit comments

Comments
 (0)