Skip to content

Commit 17db2d1

Browse files
[identity] Doc updates for GA (Azure#26787)
1 parent b70f822 commit 17db2d1

File tree

4 files changed

+80
-77
lines changed

4 files changed

+80
-77
lines changed

sdk/identity/identity/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Release History
22

3-
## 3.3.0 (2023-08-10)
3+
## 3.3.0 (2023-08-14)
44

55
### Features Added
6-
- Enabled support for logging [personally identifiable information](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/PII), required for customer support through the `enableSupportLogging` option on `loggingOptions` under `TokenCredentialOptions`.
6+
- Enabled support for logging [personally identifiable information](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/PII), required for customer support through the `enableUnsafeSupportLogging` option on `loggingOptions` under `TokenCredentialOptions`.
77
- Continuous Access Evaluation (CAE) is now configurable per-request by setting the `enable_cae` keyword argument to `True` in `get_token`. This applies to user credentials and service principal credentials. ([#26614](https://github.com/Azure/azure-sdk-for-js/pull/26614))
88

99
### Breaking Changes

sdk/identity/identity/README.md

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ If used from Node.js, the `DefaultAzureCredential` will attempt to authenticate
137137
1. **Azure CLI** - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
138138
1. **Azure PowerShell** - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
139139

140+
#### Continuation policy
141+
142+
As of version 3.3.0, `DefaultAzureCredential` will attempt to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` will continue to the next credential in the flow. Deployed service credentials will stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
143+
144+
This allows for trying all of the developer credentials on your machine while having predictable deployed behavior.
145+
140146
#### Note about `VisualStudioCodeCredential`
141147

142148
Due to a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500), `VisualStudioCodeCredential` has been removed from the `DefaultAzureCredential` token chain. When the issue is resolved in a future release, this change will be reverted.
@@ -298,6 +304,10 @@ Not all credentials require this configuration. Credentials that authenticate th
298304

299305
Configuration is attempted in the above order. For example, if values for a client secret and certificate are both present, the client secret will be used.
300306

307+
## Continuous Access Evaluation
308+
309+
As of version 3.3.0, accessing resources protected by [Continuous Access Evaluation](https://learn.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation) (CAE) is possible on a per-request basis. This can be enabled using the [`GetTokenOptions.enableCae(boolean)` API](https://learn.microsoft.com/javascript/api/@azure/core-auth/gettokenoptions?view=azure-node-latest#@azure-core-auth-gettokenoptions-enablecae). CAE isn't supported for developer credentials.
310+
301311
## Token caching
302312

303313
Token caching is a feature provided by the Azure Identity library that allows apps to:
@@ -310,69 +320,6 @@ The Azure Identity library offers both in-memory and persistent disk caching. Fo
310320

311321
## Troubleshooting
312322

313-
### Error handling
314-
315-
Credentials raise `AuthenticationError` when they fail to authenticate. This class has a `message` field which describes why authentication failed. An `AggregateAuthenticationError` will be raised by `ChainedTokenCredential` with an `errors` field containing an array of errors from each credential in the chain.
316-
317-
### Logging
318-
319-
Enabling logging may help uncover useful information about failures.
320-
321-
To see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`.
322-
You can read this environment variable from the _.env_ file by explicitly specifying a file path:
323-
324-
```javascript
325-
require("dotenv").config({ path: ".env" });
326-
```
327-
328-
Alternatively, logging can be enabled at runtime by calling `setLogLevel` from the `@azure/logger` package:
329-
330-
```typescript
331-
import { setLogLevel } from "@azure/logger";
332-
333-
setLogLevel("info");
334-
```
335-
336-
In cases where the authenticate code might be running in an environment with more than one credential available,
337-
the `@azure/identity` package offers a unique form of logging. On the optional parameters for every credential,
338-
developers can set `allowLoggingAccountIdentifiers` to true in the
339-
`loggingOptions` to log information specific to the authenticated account after
340-
each successful authentication, including the Client ID, the Tenant ID, the
341-
Object ID of the authenticated user, and if possible the User Principal Name.
342-
343-
For example, using the `DefaultAzureCredential`:
344-
345-
```ts
346-
import { setLogLevel } from "@azure/logger";
347-
348-
setLogLevel("info");
349-
350-
const credential = new DefaultAzureCredential({
351-
loggingOptions: { allowLoggingAccountIdentifiers: true },
352-
});
353-
```
354-
355-
Once that credential authenticates, the following message will appear in the logs (with the real information instead of `HIDDEN`):
356-
357-
```
358-
azure:identity:info [Authenticated account] Client ID: HIDDEN. Tenant ID: HIDDEN. User Principal Name: HIDDEN. Object ID (user): HIDDEN
359-
```
360-
361-
In cases where the user's [Personally Identifiable Information](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/PII) needs to be logged for customer support, developers can set `enableSupportLogging` to true in the
362-
`loggingOptions`.
363-
364-
For example, using the `DefaultAzureCredential`:
365-
366-
```ts
367-
import { setLogLevel } from "@azure/logger";
368-
369-
setLogLevel("info");
370-
371-
const credential = new DefaultAzureCredential({
372-
loggingOptions: { enableSupportLogging: true },
373-
});
374-
```
375-
376323
For assistance with troubleshooting, see the [troubleshooting guide](https://aka.ms/azsdk/js/identity/troubleshoot).
377324

378325
## Next steps

sdk/identity/identity/TOKEN_CACHING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ The in-memory token cache provided by the Azure Identity library:
2121

2222
**Note:** When Azure Identity library credentials are used with Azure service libraries (for example, Azure Blob Storage), the in-memory token caching is active in the `HttpPipeline` layer as well. All `TokenCredential` implementations are supported there, including custom implementations external to the Azure Identity library.
2323

24+
#### Caching cannot be disabled
25+
26+
As there are many levels of cache, it's not possible disable in-memory caching. However, the in-memory cache may be cleared by creating a new credential instance.
27+
2428
### Persistent token caching
2529

2630
*Persistent disk token caching* is an opt-in feature in the Azure Identity library. The feature allows apps to cache access tokens in an encrypted, persistent storage mechanism. As indicated in the following table, the storage mechanism differs across operating systems.

sdk/identity/identity/TROUBLESHOOTING.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ This troubleshooting guide covers the following areas of the Azure Identity clie
99
## Table of contents
1010

1111
- [Handle Azure Identity errors](#handle-azure-identity-errors)
12-
- [AuthenticationRequiredError](#authenticationrequirederror)
13-
- [CredentialUnavailableError](#credentialunavailableerror)
12+
- [AggregateAuthenticationError](#aggregateauthenticationerror)
1413
- [AuthenticationError](#authenticationerror)
14+
- [AuthenticationRequiredError](#authenticationrequirederror)
15+
- [CredentialUnavailableError](#credentialunavailableerror)
1516
- [Find relevant information in error messages](#find-relevant-information-in-error-messages)
1617
- [Enable and configure logging](#enable-and-configure-logging)
18+
- [Allow logging identifiers](#allow-logging-identifiers)
19+
- [PII Logging](#pii-logging)
1720
- [Permission issues](#permission-issues)
1821
- [Troubleshoot default Azure credential authentication issues](#troubleshoot-default-azure-credential-authentication-issues)
1922
- [Troubleshoot environment credential authentication issues](#troubleshoot-environment-credential-authentication-issues)
@@ -31,11 +34,13 @@ This troubleshooting guide covers the following areas of the Azure Identity clie
3134

3235
## Handle Azure Identity errors
3336

34-
### AuthenticationRequiredError
37+
### AggregateAuthenticationError
3538

36-
Errors arising from authentication issues can be thrown on any service client method that makes a request to the service. This is because the token is requested from the credential on the first call to the service and on any subsequent call that needs to refresh the token.
39+
An `AggregateAuthenticationError` will be raised by `ChainedTokenCredential` with an `errors` field containing an array of errors from each credential in the chain.
3740

38-
To distinguish these failures from failures in the service client, Azure Identity classes throw the `AuthenticationRequiredError`. Details describing the source of the error are provided in the error message. Depending on the application, these errors may or may not be recoverable.
41+
### AuthenticationError
42+
43+
The `AuthenticationError` is used to indicate a failure to authenticate with Azure Active Directory (Azure AD). The `errorResponse` field contains more details about the specific failure.
3944

4045
```ts
4146
import * from "@azure/identity";
@@ -51,20 +56,18 @@ async function main() {
5156
// Retrieving the properties of the existing keys in that specific Key Vault.
5257
console.log(await client.listPropertiesOfKeys().next());
5358
} catch (error) {
54-
console.log("Authentication Failed", error.message);
59+
console.log("Azure Active Directory service response with error", error.errorResponse);
5560
}
5661
}
5762

5863
main();
5964
```
6065

61-
### CredentialUnavailableError
62-
63-
The `CredentialUnavailableError` is used to indicate that the credential can't authenticate in the current environment due to lack of required configuration or setup. This error is also used as a signal to chained credential types, such as `DefaultAzureCredential` and `ChainedTokenCredential`, that the chained credential should continue to try other credential types later in the chain. In `ManagedIdentityCredential`, it can also trigger if the authentication endpoint (like the IMDS endpoint) is unavailable.
66+
### AuthenticationRequiredError
6467

65-
### AuthenticationError
68+
Errors arising from authentication issues can be thrown on any service client method that makes a request to the service. This is because the token is requested from the credential on the first call to the service and on any subsequent call that needs to refresh the token.
6669

67-
The `AuthenticationError` is used to indicate a failure to authenticate with Azure Active Directory (Azure AD). The `errorResponse` field contains more details about the specific failure.
70+
To distinguish these failures from failures in the service client, Azure Identity classes throw the `AuthenticationRequiredError`. Details describing the source of the error are provided in the error message. Depending on the application, these errors may or may not be recoverable.
6871

6972
```ts
7073
import * from "@azure/identity";
@@ -80,13 +83,17 @@ async function main() {
8083
// Retrieving the properties of the existing keys in that specific Key Vault.
8184
console.log(await client.listPropertiesOfKeys().next());
8285
} catch (error) {
83-
console.log("Azure Active Directory service response with error", error.errorResponse);
86+
console.log("Authentication Failed", error.message);
8487
}
8588
}
8689

8790
main();
8891
```
8992

93+
### CredentialUnavailableError
94+
95+
The `CredentialUnavailableError` is used to indicate that the credential can't authenticate in the current environment due to lack of required configuration or setup. This error is also used as a signal to chained credential types, such as `DefaultAzureCredential` and `ChainedTokenCredential`, that the chained credential should continue to try other credential types later in the chain. In `ManagedIdentityCredential`, it can also trigger if the authentication endpoint (like the IMDS endpoint) is unavailable.
96+
9097
## Find relevant information in error messages
9198

9299
`AuthenticationRequiredError` is thrown when unexpected errors occurred while a credential is authenticating. This can include errors received from requests to the Azure AD Security Token Service (STS) and often contains information helpful to diagnosis. Consider the following `AuthenticationRequiredError` message:
@@ -117,6 +124,13 @@ import { setLogLevel } from "@azure/logger";
117124
setLogLevel("info");
118125
```
119126

127+
Alternatively, you can set the `AZURE_LOG_LEVEL` environment variable to `info`. You can read this environment variable from the _.env_ file by explicitly specifying a file path:
128+
129+
```ts
130+
import dotenv from "dotenv";
131+
dotenv.config({path: ".env"});
132+
```
133+
120134
Consider a scenario in which you have the following environment variables set up either in your environment or _.env_ file:
121135

122136
- `AZURE_TENANT_ID`
@@ -134,6 +148,44 @@ These logging statements indicate that the `EnvironmentCredential` is being used
134148

135149
> CAUTION: Requests and responses in the Azure Identity library contain sensitive information. Precaution must be taken to protect logs when customizing the output to avoid compromising account security.
136150
151+
#### Allow logging identifiers
152+
153+
In cases where the authentication code might be running in an environment with more than one credential available, the `@azure/identity` package offers a unique form of logging. On the optional parameters for every credential, developers can set `allowLoggingAccountIdentifiers` to `true` in the `loggingOptions` to log information specific to the authenticated account after each successful authentication, including the Client ID, the Tenant ID, the Object ID of the authenticated user, and, if possible, the User Principal Name.
154+
155+
For example, using the `DefaultAzureCredential`:
156+
157+
```ts
158+
import { setLogLevel } from "@azure/logger";
159+
160+
setLogLevel("info");
161+
162+
const credential = new DefaultAzureCredential({
163+
loggingOptions: { allowLoggingAccountIdentifiers: true },
164+
});
165+
```
166+
167+
Once that credential authenticates, the following message will appear in the logs (with the real information instead of `HIDDEN`):
168+
169+
```
170+
azure:identity:info [Authenticated account] Client ID: HIDDEN. Tenant ID: HIDDEN. User Principal Name: HIDDEN. Object ID (user): HIDDEN
171+
```
172+
173+
#### PII logging
174+
175+
In cases where the user's [Personally Identifiable Information](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/PII) needs to be logged for customer support, developers can set `enableUnsafeSupportLogging` to `true` in the `loggingOptions`.
176+
177+
For example, using the `DefaultAzureCredential`:
178+
179+
```ts
180+
import { setLogLevel } from "@azure/logger";
181+
182+
setLogLevel("info");
183+
184+
const credential = new DefaultAzureCredential({
185+
loggingOptions: { enableUnsafeSupportLogging: true },
186+
});
187+
```
188+
137189
## Permission issues
138190

139191
If you're using app registration to authenticate the service, ensure the app registration has the correct permissions and role assignments in the service you want to use. For example, if you want to have access to the Azure App Configuration service through Azure AD, ensure your app registration has the permissions and role assignments for access to Azure AD. You can either be assigned the role directly or be in a group that's assigned the role. The "Contributor" and the "Owner" roles allow you to manage the App Configuration resource. In this case, you can either use "App Configuration Data Owner" directly on the user or the Azure AD group. Alternatively, use "Owner" on the Azure AD group. While the App Configuration data can be accessed using access keys, these keys don't grant direct access to the data using Azure AD.

0 commit comments

Comments
 (0)