Skip to content

Commit 9b16e95

Browse files
committed
Merge branch 'main' of https://github.com/MicrosoftDocs/azure-docs-pr into heidist-fix
2 parents 9e3f359 + 1cb5cb9 commit 9b16e95

File tree

86 files changed

+1326
-711
lines changed

Some content is hidden

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

86 files changed

+1326
-711
lines changed

.openpublishing.redirection.azure-monitor.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
"redirect_url": "/azure/azure-monitor/getting-started",
66
"redirect_document_id": false
77
},
8-
{
9-
"source_path_from_root": "/articles/azure-monitor/monitor-reference.md",
10-
"redirect_url": "/azure/azure-monitor/data-sources",
11-
"redirect_document_id": false
12-
},
138
{
149
"source_path_from_root": "/articles/azure-monitor/observability-data.md",
1510
"redirect_url": "/azure/azure-monitor/overview",

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"redirections": [
3+
{
4+
"source_path": "articles/virtual-machines/h-series-retirement.md",
5+
"redirect_url": "/previous-versions/azure/virtual-machines/h-series-retirement",
6+
"redirect_document_id": false
7+
},
38
{
49
"source_path": "articles/security/develop/security-code-analysis-customize.md",
510
"redirect_url": "/previous-versions/azure/security/develop/security-code-analysis-customize",

articles/active-directory/develop/reference-aadsts-error-codes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ The `error` field has several possible values - review the protocol documentatio
238238
| AADSTS75008 | RequestDeniedError - The request from the app was denied since the SAML request had an unexpected destination. |
239239
| AADSTS75011 | NoMatchedAuthnContextInOutputClaims - The authentication method by which the user authenticated with the service doesn't match requested authentication method. To learn more, see the troubleshooting article for error [AADSTS75011](/troubleshoot/azure/active-directory/error-code-aadsts75011-auth-method-mismatch). |
240240
| AADSTS75016 | Saml2AuthenticationRequestInvalidNameIDPolicy - SAML2 Authentication Request has invalid NameIdPolicy. |
241+
| AADSTS76026 | RequestIssueTimeExpired - IssueTime in an SAML2 Authentication Request is expired. |
241242
| AADSTS80001 | OnPremiseStoreIsNotAvailable - The Authentication Agent is unable to connect to Active Directory. Make sure that agent servers are members of the same AD forest as the users whose passwords need to be validated and they are able to connect to Active Directory. |
242243
| AADSTS80002 | OnPremisePasswordValidatorRequestTimedout - Password validation request timed out. Make sure that Active Directory is available and responding to requests from the agents. |
243244
| AADSTS80005 | OnPremisePasswordValidatorUnpredictableWebException - An unknown error occurred while processing the response from the Authentication Agent. Retry the request. If it continues to fail, [open a support ticket](../fundamentals/active-directory-troubleshooting-support-howto.md) to get more details on the error. |
@@ -368,4 +369,4 @@ The `error` field has several possible values - review the protocol documentatio
368369

369370
## Next steps
370371

371-
* Have a question or can't find what you're looking for? Create a GitHub issue or see [Support and help options for developers](./developer-support-help-options.md) to learn about other ways you can get help and support.
372+
* Have a question or can't find what you're looking for? Create a GitHub issue or see [Support and help options for developers](./developer-support-help-options.md) to learn about other ways you can get help and support.

articles/active-directory/develop/test-automate-integration-testing.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ To exclude a test application:
122122

123123
## Write your application tests
124124

125-
Now that you're set up, you can write your automated tests. The following .NET example code uses [Microsoft Authentication Library (MSAL)](msal-overview.md) and [xUnit](https://xunit.net/), a common testing framework.
125+
Now that you're set up, you can write your automated tests. The following are tests for:
126+
1. .NET example code uses [Microsoft Authentication Library (MSAL)](msal-overview.md) and [xUnit](https://xunit.net/), a common testing framework.
127+
1. JavaScript example code uses [Microsoft Authentication Library (MSAL)](msal-overview.md) and [Playwright](https://playwright.dev/), a common testing framework.
128+
129+
## [.NET](#tab/dotnet)
126130

127131
### Set up your appsettings.json file
128132

@@ -252,3 +256,112 @@ public class ApiTests : IClassFixture<ClientFixture>
252256
}
253257
}
254258
```
259+
260+
## [JavaScript](#tab/JavaScript)
261+
262+
### Set up your authConfig.json file
263+
264+
Add the client ID and the tenant ID of the test app you previously created, the key vault URI and the secret name to the authConfig.js file of your test project.
265+
266+
```javascript
267+
export const msalConfig = {
268+
auth: {
269+
clientId: 'Enter_the_Application_Id_Here',
270+
authority: 'https://login.microsoftonline.com/Enter_the_Tenant_Id_Here',
271+
},
272+
};
273+
274+
export const keyVaultConfig = {
275+
keyVaultUri: 'https://<your-unique-keyvault-name>.vault.azure.net',
276+
secretName: 'Enter_the_Secret_Name',
277+
};
278+
```
279+
280+
### Initialize MSAL.js and fetch the user credentials from Key Vault
281+
282+
Initialize the MSAL.js authentication context by instantiating a [PublicClientApplication](https://azuread.github.io/microsoft-authentication-library-for-js/ref/classes/_azure_msal_browser.publicclientapplication.html) with a [Configuration](https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal.html#configuration) object. The minimum required configuration property is the `clientID` of the application.
283+
284+
Use [SecretClient()](/javascript/api/@azure/keyvault-secrets/secretclient) to get the test username and password secrets from Azure Key Vault.
285+
286+
[DefaultAzureCredential()](/javascript/api/@azure/identity/defaultazurecredential) authenticates with Azure Key Vault by getting an access token from a service principal configured by environment variables or a managed identity (if the code is running on an Azure resource with a managed identity). If the code is running locally, `DefaultAzureCredential` uses the local user's credentials. Read more in the [Azure Identity client library](/javascript/api/@azure/identity/defaultazurecredential) content.
287+
288+
Use Microsoft Authentication Library (MSAL) to authenticate using the ROPC flow and get an access token. The access token is passed along as a bearer token in the HTTP request.
289+
290+
291+
```javascript
292+
import { test, expect } from '@playwright/test';
293+
import { DefaultAzureCredential } from '@azure/identity';
294+
import { SecretClient } from '@azure/keyvault-secrets';
295+
import { PublicClientApplication, CacheKVStore } from '@azure/msal-node';
296+
import { msalConfig, keyVaultConfig } from '../authConfig';
297+
298+
let tokenCache;
299+
const KVUri = keyVaultConfig.keyVaultUri;
300+
const secretName = keyVaultConfig.secretName;
301+
302+
async function getCredentials() {
303+
try {
304+
const credential = new DefaultAzureCredential();
305+
const secretClient = new SecretClient(KVUri, credential);
306+
const secret = await secretClient.getSecret(keyVaultConfig.secretName);
307+
const password = secret.value;
308+
return [secretName, password];
309+
} catch (error) {
310+
console.log(error);
311+
}
312+
}
313+
314+
test.beforeAll(async () => {
315+
const pca = new PublicClientApplication(msalConfig);
316+
const [username, password] = await getCredentials();
317+
const usernamePasswordRequest = {
318+
scopes: ['user.read', 'User.ReadBasic.All'],
319+
username: username,
320+
password: password,
321+
};
322+
await pca.acquireTokenByUsernamePassword(usernamePasswordRequest);
323+
tokenCache = pca.getTokenCache().getKVStore();
324+
});
325+
```
326+
327+
### Run the test suite
328+
329+
In the same file, add the tests as shown below:
330+
331+
```javascript
332+
/**
333+
* Stores the token in the session storage and reloads the page
334+
*/
335+
async function setSessionStorage(page, tokens) {
336+
const cacheKeys = Object.keys(tokens);
337+
for (let key of cacheKeys) {
338+
const value = JSON.stringify(tokenCache[key]);
339+
await page.context().addInitScript(
340+
(arr) => {
341+
window.sessionStorage.setItem(arr[0], arr[1]);
342+
},
343+
[key, value]
344+
);
345+
}
346+
await page.reload();
347+
}
348+
349+
test.describe('Testing Authentication with MSAL.js ', () => {
350+
test('Test user has signed in successfully', async ({ page }) => {
351+
await page.goto('http://localhost:<port>/');
352+
let signInButton = page.getByRole('button', { name: /Sign In/i });
353+
let signOutButton = page.getByRole('button', { name: /Sign Out/i });
354+
let welcomeDev = page.getByTestId('WelcomeMessage');
355+
expect(await signInButton.count()).toBeGreaterThan(0);
356+
expect(await signOutButton.count()).toBeLessThanOrEqual(0);
357+
expect(await welcomeDev.innerHTML()).toEqual('Please sign-in to see your profile and read your mails');
358+
await setSessionStorage(page, tokenCache);
359+
expect(await signInButton.count()).toBeLessThanOrEqual(0);
360+
expect(await signOutButton.count()).toBeGreaterThan(0);
361+
expect(await welcomeDev.innerHTML()).toContain(`Welcome`);
362+
});
363+
});
364+
365+
```
366+
367+
For more information, please check the following code sample [MSAL.js Testing Example](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-browser-samples/TestingSample).

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Sign in Azure AD users by using the Microsoft identity platform's i
44
author: OwenRichards1
55
manager: CelesteDG
66
ms.custom: aaddev, identityplatformtop40
7-
ms.date: 08/26/2022
7+
ms.date: 02/14/2023
88
ms.author: owenrichards
99
ms.reviewer: ludwignick
1010
ms.service: active-directory
@@ -14,45 +14,43 @@ ms.topic: conceptual
1414

1515
# OpenID Connect on the Microsoft identity platform
1616

17-
OpenID Connect (OIDC) extends the OAuth 2.0 authorization protocol for use also as an authentication protocol. You can use OIDC to enable single sign-on (SSO) between your OAuth-enabled applications by using a security token called an *ID token*.
17+
OpenID Connect (OIDC) extends the OAuth 2.0 authorization protocol for use as an additional authentication protocol. You can use OIDC to enable single sign-on (SSO) between your OAuth-enabled applications by using a security token called an *ID token*.
1818

1919
The full specification for OIDC is available on the OpenID Foundation's website at [OpenID Connect Core 1.0 specification](https://openid.net/specs/openid-connect-core-1_0.html).
2020

2121
## Protocol flow: Sign-in
2222

23-
This diagram shows the basic OpenID Connect sign-in flow. The steps in the flow are described in more detail in later sections of the article.
23+
The following diagram shows the basic OpenID Connect sign-in flow. The steps in the flow are described in more detail in later sections of the article.
2424

2525
![Swim-lane diagram showing the OpenID Connect protocol's sign-in flow.](./media/v2-protocols-oidc/convergence-scenarios-webapp.svg)
2626

2727
[!INCLUDE [try-in-postman-link](includes/try-in-postman-link.md)]
2828

2929
## Enable ID tokens
3030

31-
The *ID token* introduced by OpenID Connect is issued by the authorization server (the Microsoft identity platform) when the client application requests one during user authentication. The ID token enables a client application to verify the identity of the user and to get other information (claims) about them.
31+
The *ID token* introduced by OpenID Connect is issued by the authorization server, the Microsoft identity platform, when the client application requests one during user authentication. The ID token enables a client application to verify the identity of the user and to get other information (claims) about them.
3232

33-
ID tokens aren't issued by default for an application registered with the Microsoft identity platform. Enable ID tokens for an app by using one of the following methods.
33+
ID tokens aren't issued by default for an application registered with the Microsoft identity platform. ID tokens for an application are enabled by using one of the following methods:
3434

35-
To enable ID tokens for your app, navigate to the [Azure portal](https://portal.azure.com) and then:
36-
37-
1. Select **Azure Active Directory** > **App registrations** > *\<your application\>* > **Authentication**.
35+
1. Navigate to the [Azure portal](https://portal.azure.com) and select **Azure Active Directory** > **App registrations** > *\<your application\>* > **Authentication**.
3836
1. Under **Implicit grant and hybrid flows**, select the **ID tokens (used for implicit and hybrid flows)** checkbox.
3937

4038
Or:
4139

4240
1. Select **Azure Active Directory** > **App registrations** > *\<your application\>* > **Manifest**.
4341
1. Set `oauth2AllowIdTokenImplicitFlow` to `true` in the app registration's [application manifest](reference-app-manifest.md).
4442

45-
If you forget to enable ID tokens for your app and you request one, the Microsoft identity platform returns an `unsupported_response` error similar to:
43+
If ID tokens are not enabled for your app and one is requested, the Microsoft identity platform returns an `unsupported_response` error similar to:
4644

4745
> *The provided value for the input parameter 'response_type' isn't allowed for this client. Expected value is 'code'*.
4846
49-
Requesting an ID token by specifying a `response_type` of `id_token` is explained in [Send the sign-in request](#send-the-sign-in-request) later in the article.
47+
Requesting an ID token by specifying a `response_type` of `code` is explained in [Send the sign-in request](#send-the-sign-in-request) later in the article.
5048

5149
## Fetch the OpenID configuration document
5250

53-
OpenID providers like the Microsoft identity platform provide an [OpenID Provider Configuration Document](https://openid.net/specs/openid-connect-discovery-1_0.html) at a publicly accessible endpoint containing the provider's OIDC endpoints, supported claims, and other metadata. Client applications can use the metadata to discover the URLs to use for authentication and the authentication service's public signing keys, among other things.
51+
OpenID providers like the Microsoft identity platform provide an [OpenID Provider Configuration Document](https://openid.net/specs/openid-connect-discovery-1_0.html) at a publicly accessible endpoint containing the provider's OIDC endpoints, supported claims, and other metadata. Client applications can use the metadata to discover the URLs to use for authentication and the authentication service's public signing keys.
5452

55-
Authentication libraries are the most common consumers of the OpenID configuration document, which they use for discovery of authentication URLs, the provider's public signing keys, and other service metadata. If you use an authentication library in your app (recommended), you likely won't need to hand-code requests to and responses from the OpenID configuration document endpoint.
53+
Authentication libraries are the most common consumers of the OpenID configuration document, which they use for discovery of authentication URLs, the provider's public signing keys, and other service metadata. If an authentication library is used in your app, you likely won't need to hand-code requests to and responses from the OpenID configuration document endpoint.
5654

5755
### Find your app's OpenID configuration document URI
5856

@@ -73,16 +71,14 @@ The value of `{tenant}` varies based on the application's sign-in audience as sh
7371
> [!TIP]
7472
> Note that when using the `common` or `consumers` authority for personal Microsoft accounts, the consuming resource application must be configured to support such type of accounts in accordance with [signInAudience](./supported-accounts-validation.md).
7573
76-
You can also find your app's OpenID configuration document URI in its app registration in the Azure portal.
77-
78-
To find the OIDC configuration document for your app, navigate to the [Azure portal](https://portal.azure.com) and then:
74+
To find the OIDC configuration document in the Azure portal, navigate to the [Azure portal](https://portal.azure.com) and then:
7975

8076
1. Select **Azure Active Directory** > **App registrations** > *\<your application\>* > **Endpoints**.
8177
1. Locate the URI under **OpenID Connect metadata document**.
8278

8379
### Sample request
8480

85-
This request gets the OpenID configuration metadata from the `common` authority's OpenID configuration document endpoint on the Azure public cloud:
81+
The following request gets the OpenID configuration metadata from the `common` authority's OpenID configuration document endpoint on the Azure public cloud:
8682

8783
```http
8884
GET /common/v2.0/.well-known/openid-configuration
@@ -112,16 +108,12 @@ The configuration metadata is returned in JSON format as shown in the following
112108
...
113109
}
114110
```
115-
116-
<!-- UNCOMMENT WHEN THE EXAMPLE APP REGISTRATION IS RE-ENABLED -->
117-
<!-- If your app has custom signing keys as a result of using [claims mapping](active-directory-claims-mapping.md), append the `appid` query parameter to include the `jwks_uri` claim that includes your app's signing key information. For example, `https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration?appid=6731de76-14a6-49ae-97bc-6eba6914391e` includes a `jwks_uri` of `https://login.microsoftonline.com/{tenant}/discovery/v2.0/keys?appid=6731de76-14a6-49ae-97bc-6eba6914391e`. -->
118-
119111
## Send the sign-in request
120112

121113
To authenticate a user and request an ID token for use in your application, direct their user-agent to the Microsoft identity platform's _/authorize_ endpoint. The request is similar to the first leg of the [OAuth 2.0 authorization code flow](v2-oauth2-auth-code-flow.md) but with these distinctions:
122114

123115
* Include the `openid` scope in the `scope` parameter.
124-
* Specify `id_token` or `code+id_token` in the `response_type` parameter.
116+
* Specify `code` in the `response_type` parameter.
125117
* Include the `nonce` parameter.
126118

127119
Example sign-in request (line breaks included only for readability):
@@ -141,7 +133,7 @@ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
141133
| --- | --- | --- |
142134
| `tenant` | Required | You can use the `{tenant}` value in the path of the request to control who can sign in to the application. The allowed values are `common`, `organizations`, `consumers`, and tenant identifiers. For more information, see [protocol basics](active-directory-v2-protocols.md#endpoints). Critically, for guest scenarios where you sign a user from one tenant into another tenant, you *must* provide the tenant identifier to correctly sign them into the resource tenant.|
143135
| `client_id` | Required | The **Application (client) ID** that the [Azure portal – App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) experience assigned to your app. |
144-
| `response_type` | Required | Must include `id_token` for OpenID Connect sign-in. It might also include other `response_type` values, such as `code`. |
136+
| `response_type` | Required | Must include `code` for OpenID Connect sign-in. |
145137
| `redirect_uri` | Recommended | The redirect URI of your app, where authentication responses can be sent and received by your app. It must exactly match one of the redirect URIs you registered in the portal, except that it must be URL-encoded. If not present, the endpoint will pick one registered `redirect_uri` at random to send the user back to. |
146138
| `scope` | Required | A space-separated list of scopes. For OpenID Connect, it must include the scope `openid`, which translates to the **Sign you in** permission in the consent UI. You might also include other scopes in this request for requesting consent. |
147139
| `nonce` | Required | A value generated and sent by your app in its request for an ID token. The same `nonce` value is included in the ID token returned to your app by the Microsoft identity platform. To mitigate token replay attacks, your app should verify the `nonce` value in the ID token is the same value it sent when requesting the token. The value is typically a unique, random string. |

0 commit comments

Comments
 (0)