Skip to content

Commit fb1d2b2

Browse files
committed
[Identity] Update logging and dependency versions for MSAL (#23960)
1 parent ac29ebe commit fb1d2b2

6 files changed

Lines changed: 57 additions & 16 deletions

File tree

common/config/rush/pnpm-lock.yaml

Lines changed: 25 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/identity/identity/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Release History
2-
32
## 3.1.2 (Unreleased)
43

54
### Features Added
@@ -8,8 +7,11 @@
87

98
### Bugs Fixed
109

10+
- Enable msal logging based on log level specified by user.
1111
### Other Changes
1212

13+
- Upgraded version dependencies on msal libraries, since they have additional logging enabled.
14+
1315
## 3.1.1 (2022-11-18)
1416

1517
### Bugs Fixed

sdk/identity/identity/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110
"@azure/core-tracing": "^1.0.0",
111111
"@azure/core-util": "^1.0.0",
112112
"@azure/logger": "^1.0.0",
113-
"@azure/msal-browser": "^2.26.0",
114-
"@azure/msal-common": "^7.0.0",
115-
"@azure/msal-node": "^1.14.2",
113+
"@azure/msal-browser": "^2.32.0",
114+
"@azure/msal-common": "^9.0.0",
115+
"@azure/msal-node": "^1.14.4",
116116
"events": "^3.0.0",
117117
"jws": "^4.0.0",
118118
"open": "^8.0.0",

sdk/identity/identity/src/msal/browserFlows/msalAuthCode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
import * as msalBrowser from "@azure/msal-browser";
55
import { MsalBrowser, MsalBrowserFlowOptions } from "./msalBrowserCommon";
6-
import { defaultLoggerCallback, msalToPublic, publicToMsal } from "../utils";
6+
import { defaultLoggerCallback, msalToPublic, publicToMsal, getMSALLogLevel } from "../utils";
77
import { AccessToken } from "@azure/core-auth";
88
import { AuthenticationRecord } from "../types";
99
import { AuthenticationRequiredError } from "../../errors";
1010
import { CredentialFlowGetTokenOptions } from "../credentials";
11+
import { getLogLevel } from "@azure/logger";
1112

1213
// We keep a copy of the redirect hash.
1314
const redirectHash = self.location.hash;
@@ -38,6 +39,7 @@ export class MSALAuthCode extends MsalBrowser {
3839
this.msalConfig.system = {
3940
loggerOptions: {
4041
loggerCallback: defaultLoggerCallback(this.logger, "Browser"),
42+
logLevel: getMSALLogLevel(getLogLevel()),
4143
},
4244
};
4345

sdk/identity/identity/src/msal/nodeFlows/msalNodeCommon.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import * as msalCommon from "@azure/msal-common";
55
import * as msalNode from "@azure/msal-node";
66
import { AccessToken, GetTokenOptions } from "@azure/core-auth";
7+
import { getLogLevel } from "@azure/logger";
78
import {
89
MsalBaseUtilities,
910
defaultLoggerCallback,
1011
getAuthority,
1112
getKnownAuthorities,
1213
msalToPublic,
1314
publicToMsal,
15+
getMSALLogLevel,
1416
} from "../utils";
1517
import { MsalFlow, MsalFlowOptions } from "../flows";
1618
import {
@@ -163,6 +165,7 @@ export abstract class MsalNode extends MsalBaseUtilities implements MsalFlow {
163165
networkClient: this.identityClient,
164166
loggerOptions: {
165167
loggerCallback: defaultLoggerCallback(options.logger),
168+
logLevel: getMSALLogLevel(getLogLevel()),
166169
},
167170
},
168171
};

sdk/identity/identity/src/msal/utils.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { AbortError } from "@azure/abort-controller";
1212
import { MsalFlowOptions } from "./flows";
1313
import { isNode } from "@azure/core-util";
1414
import { v4 as uuidv4 } from "uuid";
15+
import { AzureLogLevel } from "@azure/logger";
1516

1617
/**
1718
* Latest AuthenticationRecord version
@@ -110,6 +111,25 @@ export const defaultLoggerCallback: (
110111
}
111112
};
112113

114+
/**
115+
* @internal
116+
*/
117+
export function getMSALLogLevel(logLevel: AzureLogLevel | undefined): msalCommon.LogLevel {
118+
switch (logLevel) {
119+
case "error":
120+
return msalCommon.LogLevel.Error;
121+
case "info":
122+
return msalCommon.LogLevel.Info;
123+
case "verbose":
124+
return msalCommon.LogLevel.Verbose;
125+
case "warning":
126+
return msalCommon.LogLevel.Warning;
127+
default:
128+
// default msal logging level should be Info
129+
return msalCommon.LogLevel.Info;
130+
}
131+
}
132+
113133
/**
114134
* The common utility functions for the MSAL clients.
115135
* Defined as a class so that the classes extending this one can have access to its methods and protected properties.

0 commit comments

Comments
 (0)