@azure/msal-node 2.12.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/ITokenCache.d.ts +15 -15
- package/dist/cache/NodeStorage.cjs +423 -423
- package/dist/cache/NodeStorage.d.ts +193 -193
- package/dist/cache/NodeStorage.mjs +423 -423
- package/dist/cache/TokenCache.cjs +265 -265
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.mjs +265 -265
- package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
- package/dist/cache/distributed/ICacheClient.d.ts +17 -17
- package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
- package/dist/cache/serializer/Deserializer.cjs +167 -167
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.mjs +167 -167
- package/dist/cache/serializer/Serializer.cjs +137 -137
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.mjs +137 -137
- package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
- package/dist/client/ClientApplication.cjs +334 -334
- package/dist/client/ClientApplication.d.ts +143 -143
- package/dist/client/ClientApplication.mjs +334 -334
- package/dist/client/ClientAssertion.cjs +143 -143
- package/dist/client/ClientAssertion.d.ts +55 -55
- package/dist/client/ClientAssertion.mjs +143 -143
- package/dist/client/ClientCredentialClient.cjs +194 -194
- package/dist/client/ClientCredentialClient.d.ts +33 -33
- package/dist/client/ClientCredentialClient.mjs +194 -194
- package/dist/client/ConfidentialClientApplication.cjs +169 -169
- package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.mjs +169 -169
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.cjs +207 -207
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.mjs +207 -207
- package/dist/client/IConfidentialClientApplication.d.ts +39 -39
- package/dist/client/IPublicClientApplication.d.ts +42 -42
- package/dist/client/ManagedIdentityApplication.cjs +84 -84
- package/dist/client/ManagedIdentityApplication.d.ts +30 -30
- package/dist/client/ManagedIdentityApplication.mjs +84 -84
- package/dist/client/ManagedIdentityClient.cjs +60 -60
- package/dist/client/ManagedIdentityClient.d.ts +27 -27
- package/dist/client/ManagedIdentityClient.mjs +60 -60
- package/dist/client/ManagedIdentitySources/AppService.cjs +45 -45
- package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -17
- package/dist/client/ManagedIdentitySources/AppService.mjs +45 -45
- package/dist/client/ManagedIdentitySources/AzureArc.cjs +155 -120
- package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +27 -23
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +155 -122
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +122 -122
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +30 -30
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +122 -122
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.cjs +38 -38
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +16 -16
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +38 -38
- package/dist/client/ManagedIdentitySources/Imds.cjs +43 -43
- package/dist/client/ManagedIdentitySources/Imds.d.ts +12 -12
- package/dist/client/ManagedIdentitySources/Imds.mjs +43 -43
- package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +54 -54
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +17 -17
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +54 -54
- package/dist/client/OnBehalfOfClient.cjs +202 -202
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.mjs +202 -202
- package/dist/client/PublicClientApplication.cjs +237 -237
- package/dist/client/PublicClientApplication.d.ts +72 -72
- package/dist/client/PublicClientApplication.mjs +237 -237
- package/dist/client/UsernamePasswordClient.cjs +95 -95
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.mjs +95 -95
- package/dist/config/Configuration.cjs +106 -106
- package/dist/config/Configuration.d.ts +131 -131
- package/dist/config/Configuration.mjs +106 -106
- package/dist/config/ManagedIdentityId.cjs +48 -48
- package/dist/config/ManagedIdentityId.d.ts +11 -11
- package/dist/config/ManagedIdentityId.mjs +48 -48
- package/dist/config/ManagedIdentityRequestParameters.cjs +28 -28
- package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
- package/dist/config/ManagedIdentityRequestParameters.mjs +28 -28
- package/dist/crypto/CryptoProvider.cjs +89 -89
- package/dist/crypto/CryptoProvider.d.ts +62 -62
- package/dist/crypto/CryptoProvider.mjs +89 -89
- package/dist/crypto/GuidGenerator.cjs +22 -22
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.mjs +22 -22
- package/dist/crypto/HashUtils.cjs +13 -13
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.mjs +13 -13
- package/dist/crypto/PkceGenerator.cjs +49 -49
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.mjs +49 -49
- package/dist/error/ManagedIdentityError.cjs +41 -41
- package/dist/error/ManagedIdentityError.d.ts +30 -30
- package/dist/error/ManagedIdentityError.mjs +41 -41
- package/dist/error/ManagedIdentityErrorCodes.cjs +24 -24
- package/dist/error/ManagedIdentityErrorCodes.d.ts +22 -22
- package/dist/error/ManagedIdentityErrorCodes.mjs +24 -24
- package/dist/error/NodeAuthError.cjs +95 -95
- package/dist/error/NodeAuthError.d.ts +73 -73
- package/dist/error/NodeAuthError.mjs +95 -95
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +45 -45
- package/dist/index.mjs +1 -1
- package/dist/internals.cjs +8 -8
- package/dist/internals.d.ts +6 -6
- package/dist/internals.mjs +8 -8
- package/dist/network/HttpClient.cjs +281 -281
- package/dist/network/HttpClient.d.ts +25 -25
- package/dist/network/HttpClient.mjs +281 -281
- package/dist/network/HttpClientWithRetries.cjs +34 -34
- package/dist/network/HttpClientWithRetries.d.ts +11 -11
- package/dist/network/HttpClientWithRetries.mjs +34 -34
- package/dist/network/ILoopbackClient.d.ts +10 -10
- package/dist/network/LoopbackClient.cjs +81 -77
- package/dist/network/LoopbackClient.cjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +81 -77
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.cjs +4 -4
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +4 -4
- package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
- package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
- package/dist/request/ClientCredentialRequest.d.ts +14 -14
- package/dist/request/DeviceCodeRequest.d.ts +15 -15
- package/dist/request/InteractiveRequest.d.ts +22 -22
- package/dist/request/ManagedIdentityRequest.d.ts +8 -8
- package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
- package/dist/request/OnBehalfOfRequest.d.ts +14 -14
- package/dist/request/RefreshTokenRequest.d.ts +17 -17
- package/dist/request/SignOutRequest.d.ts +5 -5
- package/dist/request/SilentFlowRequest.d.ts +16 -16
- package/dist/request/UsernamePasswordRequest.d.ts +19 -19
- package/dist/response/ManagedIdentityTokenResponse.d.ts +34 -34
- package/dist/retry/IHttpRetryPolicy.d.ts +5 -5
- package/dist/retry/LinearRetryPolicy.cjs +40 -40
- package/dist/retry/LinearRetryPolicy.d.ts +11 -11
- package/dist/retry/LinearRetryPolicy.mjs +40 -40
- package/dist/utils/Constants.cjs +136 -136
- package/dist/utils/Constants.d.ts +141 -141
- package/dist/utils/Constants.mjs +136 -136
- package/dist/utils/EncodingUtils.cjs +44 -44
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.mjs +44 -44
- package/dist/utils/NetworkUtils.cjs +38 -38
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.mjs +38 -38
- package/package.json +2 -2
- package/src/client/ConfidentialClientApplication.ts +3 -3
- package/src/client/ManagedIdentitySources/AzureArc.ts +80 -25
- package/src/network/LoopbackClient.ts +7 -1
- package/src/packageMetadata.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.13.1 2024-08-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -6,48 +6,48 @@ var ManagedIdentityRequestParameters = require('../../config/ManagedIdentityRequ
|
|
|
6
6
|
var BaseManagedIdentitySource = require('./BaseManagedIdentitySource.cjs');
|
|
7
7
|
var Constants = require('../../utils/Constants.cjs');
|
|
8
8
|
|
|
9
|
-
/*
|
|
10
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
-
* Licensed under the MIT License.
|
|
12
|
-
*/
|
|
13
|
-
// IMDS constants. Docs for IMDS are available here https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
|
14
|
-
const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
15
|
-
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
16
|
-
const IMDS_API_VERSION = "2018-02-01";
|
|
17
|
-
// Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
18
|
-
class Imds extends BaseManagedIdentitySource.BaseManagedIdentitySource {
|
|
19
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
20
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
21
|
-
this.identityEndpoint = identityEndpoint;
|
|
22
|
-
}
|
|
23
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
24
|
-
let validatedIdentityEndpoint;
|
|
25
|
-
if (process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
26
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]) {
|
|
27
|
-
logger.info(`[Managed Identity] Environment variable ${Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} for ${Constants.ManagedIdentitySourceNames.IMDS} returned endpoint: ${process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
28
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}`);
|
|
29
|
-
validatedIdentityEndpoint = Imds.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST, `${process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
30
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}${IMDS_TOKEN_PATH}`, Constants.ManagedIdentitySourceNames.IMDS, logger);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
logger.info(`[Managed Identity] Unable to find ${Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} environment variable for ${Constants.ManagedIdentitySourceNames.IMDS}, using the default endpoint.`);
|
|
34
|
-
validatedIdentityEndpoint = DEFAULT_IMDS_ENDPOINT;
|
|
35
|
-
}
|
|
36
|
-
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, validatedIdentityEndpoint);
|
|
37
|
-
}
|
|
38
|
-
createRequest(resource, managedIdentityId) {
|
|
39
|
-
const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
|
|
40
|
-
request.headers[Constants.METADATA_HEADER_NAME] = "true";
|
|
41
|
-
request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
|
|
42
|
-
IMDS_API_VERSION;
|
|
43
|
-
request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
44
|
-
resource;
|
|
45
|
-
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
46
|
-
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
47
|
-
}
|
|
48
|
-
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
49
|
-
return request;
|
|
50
|
-
}
|
|
9
|
+
/*
|
|
10
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
+
* Licensed under the MIT License.
|
|
12
|
+
*/
|
|
13
|
+
// IMDS constants. Docs for IMDS are available here https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
|
14
|
+
const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
15
|
+
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
16
|
+
const IMDS_API_VERSION = "2018-02-01";
|
|
17
|
+
// Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
18
|
+
class Imds extends BaseManagedIdentitySource.BaseManagedIdentitySource {
|
|
19
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
20
|
+
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
21
|
+
this.identityEndpoint = identityEndpoint;
|
|
22
|
+
}
|
|
23
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
24
|
+
let validatedIdentityEndpoint;
|
|
25
|
+
if (process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
26
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]) {
|
|
27
|
+
logger.info(`[Managed Identity] Environment variable ${Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} for ${Constants.ManagedIdentitySourceNames.IMDS} returned endpoint: ${process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
28
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}`);
|
|
29
|
+
validatedIdentityEndpoint = Imds.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST, `${process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
30
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}${IMDS_TOKEN_PATH}`, Constants.ManagedIdentitySourceNames.IMDS, logger);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
logger.info(`[Managed Identity] Unable to find ${Constants.ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} environment variable for ${Constants.ManagedIdentitySourceNames.IMDS}, using the default endpoint.`);
|
|
34
|
+
validatedIdentityEndpoint = DEFAULT_IMDS_ENDPOINT;
|
|
35
|
+
}
|
|
36
|
+
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, validatedIdentityEndpoint);
|
|
37
|
+
}
|
|
38
|
+
createRequest(resource, managedIdentityId) {
|
|
39
|
+
const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
|
|
40
|
+
request.headers[Constants.METADATA_HEADER_NAME] = "true";
|
|
41
|
+
request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
|
|
42
|
+
IMDS_API_VERSION;
|
|
43
|
+
request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
44
|
+
resource;
|
|
45
|
+
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
46
|
+
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
47
|
+
}
|
|
48
|
+
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
49
|
+
return request;
|
|
50
|
+
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
exports.Imds = Imds;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { INetworkModule, Logger } from "@azure/msal-common";
|
|
2
|
-
import { ManagedIdentityId } from "../../config/ManagedIdentityId";
|
|
3
|
-
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
|
|
4
|
-
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
|
|
5
|
-
import { CryptoProvider } from "../../crypto/CryptoProvider";
|
|
6
|
-
import { NodeStorage } from "../../cache/NodeStorage";
|
|
7
|
-
export declare class Imds extends BaseManagedIdentitySource {
|
|
8
|
-
private identityEndpoint;
|
|
9
|
-
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string);
|
|
10
|
-
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider): Imds;
|
|
11
|
-
createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
12
|
-
}
|
|
1
|
+
import { INetworkModule, Logger } from "@azure/msal-common";
|
|
2
|
+
import { ManagedIdentityId } from "../../config/ManagedIdentityId";
|
|
3
|
+
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
|
|
4
|
+
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
|
|
5
|
+
import { CryptoProvider } from "../../crypto/CryptoProvider";
|
|
6
|
+
import { NodeStorage } from "../../cache/NodeStorage";
|
|
7
|
+
export declare class Imds extends BaseManagedIdentitySource {
|
|
8
|
+
private identityEndpoint;
|
|
9
|
+
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string);
|
|
10
|
+
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider): Imds;
|
|
11
|
+
createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=Imds.d.ts.map
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.13.1 2024-08-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { ManagedIdentityRequestParameters } from '../../config/ManagedIdentityRequestParameters.mjs';
|
|
4
4
|
import { BaseManagedIdentitySource } from './BaseManagedIdentitySource.mjs';
|
|
5
5
|
import { ManagedIdentityEnvironmentVariableNames, ManagedIdentitySourceNames, METADATA_HEADER_NAME, API_VERSION_QUERY_PARAMETER_NAME, RESOURCE_BODY_OR_QUERY_PARAMETER_NAME, ManagedIdentityIdType, HttpMethod } from '../../utils/Constants.mjs';
|
|
6
6
|
|
|
7
|
-
/*
|
|
8
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
-
* Licensed under the MIT License.
|
|
10
|
-
*/
|
|
11
|
-
// IMDS constants. Docs for IMDS are available here https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
|
12
|
-
const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
13
|
-
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
14
|
-
const IMDS_API_VERSION = "2018-02-01";
|
|
15
|
-
// Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
16
|
-
class Imds extends BaseManagedIdentitySource {
|
|
17
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
18
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
19
|
-
this.identityEndpoint = identityEndpoint;
|
|
20
|
-
}
|
|
21
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
22
|
-
let validatedIdentityEndpoint;
|
|
23
|
-
if (process.env[ManagedIdentityEnvironmentVariableNames
|
|
24
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]) {
|
|
25
|
-
logger.info(`[Managed Identity] Environment variable ${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} for ${ManagedIdentitySourceNames.IMDS} returned endpoint: ${process.env[ManagedIdentityEnvironmentVariableNames
|
|
26
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}`);
|
|
27
|
-
validatedIdentityEndpoint = Imds.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST, `${process.env[ManagedIdentityEnvironmentVariableNames
|
|
28
|
-
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}${IMDS_TOKEN_PATH}`, ManagedIdentitySourceNames.IMDS, logger);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
logger.info(`[Managed Identity] Unable to find ${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} environment variable for ${ManagedIdentitySourceNames.IMDS}, using the default endpoint.`);
|
|
32
|
-
validatedIdentityEndpoint = DEFAULT_IMDS_ENDPOINT;
|
|
33
|
-
}
|
|
34
|
-
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, validatedIdentityEndpoint);
|
|
35
|
-
}
|
|
36
|
-
createRequest(resource, managedIdentityId) {
|
|
37
|
-
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
38
|
-
request.headers[METADATA_HEADER_NAME] = "true";
|
|
39
|
-
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
40
|
-
IMDS_API_VERSION;
|
|
41
|
-
request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
42
|
-
resource;
|
|
43
|
-
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
44
|
-
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
45
|
-
}
|
|
46
|
-
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
47
|
-
return request;
|
|
48
|
-
}
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
* Licensed under the MIT License.
|
|
10
|
+
*/
|
|
11
|
+
// IMDS constants. Docs for IMDS are available here https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
|
12
|
+
const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
13
|
+
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
14
|
+
const IMDS_API_VERSION = "2018-02-01";
|
|
15
|
+
// Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
16
|
+
class Imds extends BaseManagedIdentitySource {
|
|
17
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
18
|
+
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
19
|
+
this.identityEndpoint = identityEndpoint;
|
|
20
|
+
}
|
|
21
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
22
|
+
let validatedIdentityEndpoint;
|
|
23
|
+
if (process.env[ManagedIdentityEnvironmentVariableNames
|
|
24
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]) {
|
|
25
|
+
logger.info(`[Managed Identity] Environment variable ${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} for ${ManagedIdentitySourceNames.IMDS} returned endpoint: ${process.env[ManagedIdentityEnvironmentVariableNames
|
|
26
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}`);
|
|
27
|
+
validatedIdentityEndpoint = Imds.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST, `${process.env[ManagedIdentityEnvironmentVariableNames
|
|
28
|
+
.AZURE_POD_IDENTITY_AUTHORITY_HOST]}${IMDS_TOKEN_PATH}`, ManagedIdentitySourceNames.IMDS, logger);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
logger.info(`[Managed Identity] Unable to find ${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} environment variable for ${ManagedIdentitySourceNames.IMDS}, using the default endpoint.`);
|
|
32
|
+
validatedIdentityEndpoint = DEFAULT_IMDS_ENDPOINT;
|
|
33
|
+
}
|
|
34
|
+
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, validatedIdentityEndpoint);
|
|
35
|
+
}
|
|
36
|
+
createRequest(resource, managedIdentityId) {
|
|
37
|
+
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
38
|
+
request.headers[METADATA_HEADER_NAME] = "true";
|
|
39
|
+
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
40
|
+
IMDS_API_VERSION;
|
|
41
|
+
request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
42
|
+
resource;
|
|
43
|
+
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
44
|
+
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
45
|
+
}
|
|
46
|
+
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
47
|
+
return request;
|
|
48
|
+
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export { Imds };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.13.1 2024-08-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -6,59 +6,59 @@ var ManagedIdentityRequestParameters = require('../../config/ManagedIdentityRequ
|
|
|
6
6
|
var BaseManagedIdentitySource = require('./BaseManagedIdentitySource.cjs');
|
|
7
7
|
var Constants = require('../../utils/Constants.cjs');
|
|
8
8
|
|
|
9
|
-
/*
|
|
10
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
-
* Licensed under the MIT License.
|
|
12
|
-
*/
|
|
13
|
-
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
14
|
-
const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
15
|
-
/**
|
|
16
|
-
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
17
|
-
*/
|
|
18
|
-
class ServiceFabric extends BaseManagedIdentitySource.BaseManagedIdentitySource {
|
|
19
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
20
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
21
|
-
this.identityEndpoint = identityEndpoint;
|
|
22
|
-
this.identityHeader = identityHeader;
|
|
23
|
-
}
|
|
24
|
-
static getEnvironmentVariables() {
|
|
25
|
-
const identityEndpoint = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
26
|
-
const identityHeader = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
27
|
-
const identityServerThumbprint = process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
28
|
-
.IDENTITY_SERVER_THUMBPRINT];
|
|
29
|
-
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
30
|
-
}
|
|
31
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
32
|
-
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
33
|
-
/*
|
|
34
|
-
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
35
|
-
* environment variables are undefined, this MSI provider is unavailable.
|
|
36
|
-
*/
|
|
37
|
-
if (!identityEndpoint || !identityHeader || !identityServerThumbprint) {
|
|
38
|
-
logger.info(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity is unavailable because one or all of the '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}', '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' or '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_SERVER_THUMBPRINT}' environment variables are not defined.`);
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const validatedIdentityEndpoint = ServiceFabric.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, Constants.ManagedIdentitySourceNames.SERVICE_FABRIC, logger);
|
|
42
|
-
logger.info(`[Managed Identity] Environment variables validation passed for ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity.`);
|
|
43
|
-
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
44
|
-
logger.warning(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} user assigned managed identity is configured in the cluster, not during runtime. See also: https://learn.microsoft.com/en-us/azure/service-fabric/configure-existing-cluster-enable-managed-identity-token-service.`);
|
|
45
|
-
}
|
|
46
|
-
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
47
|
-
}
|
|
48
|
-
createRequest(resource, managedIdentityId) {
|
|
49
|
-
const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
|
|
50
|
-
request.headers[Constants.SERVICE_FABRIC_SECRET_HEADER_NAME] =
|
|
51
|
-
this.identityHeader;
|
|
52
|
-
request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
|
|
53
|
-
SERVICE_FABRIC_MSI_API_VERSION;
|
|
54
|
-
request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
55
|
-
resource;
|
|
56
|
-
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
57
|
-
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
58
|
-
}
|
|
59
|
-
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
60
|
-
return request;
|
|
61
|
-
}
|
|
9
|
+
/*
|
|
10
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
+
* Licensed under the MIT License.
|
|
12
|
+
*/
|
|
13
|
+
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
14
|
+
const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
15
|
+
/**
|
|
16
|
+
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
17
|
+
*/
|
|
18
|
+
class ServiceFabric extends BaseManagedIdentitySource.BaseManagedIdentitySource {
|
|
19
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
20
|
+
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
21
|
+
this.identityEndpoint = identityEndpoint;
|
|
22
|
+
this.identityHeader = identityHeader;
|
|
23
|
+
}
|
|
24
|
+
static getEnvironmentVariables() {
|
|
25
|
+
const identityEndpoint = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
26
|
+
const identityHeader = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
27
|
+
const identityServerThumbprint = process.env[Constants.ManagedIdentityEnvironmentVariableNames
|
|
28
|
+
.IDENTITY_SERVER_THUMBPRINT];
|
|
29
|
+
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
30
|
+
}
|
|
31
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
32
|
+
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
33
|
+
/*
|
|
34
|
+
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
35
|
+
* environment variables are undefined, this MSI provider is unavailable.
|
|
36
|
+
*/
|
|
37
|
+
if (!identityEndpoint || !identityHeader || !identityServerThumbprint) {
|
|
38
|
+
logger.info(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity is unavailable because one or all of the '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}', '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' or '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_SERVER_THUMBPRINT}' environment variables are not defined.`);
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const validatedIdentityEndpoint = ServiceFabric.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, Constants.ManagedIdentitySourceNames.SERVICE_FABRIC, logger);
|
|
42
|
+
logger.info(`[Managed Identity] Environment variables validation passed for ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity.`);
|
|
43
|
+
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
44
|
+
logger.warning(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.SERVICE_FABRIC} user assigned managed identity is configured in the cluster, not during runtime. See also: https://learn.microsoft.com/en-us/azure/service-fabric/configure-existing-cluster-enable-managed-identity-token-service.`);
|
|
45
|
+
}
|
|
46
|
+
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
47
|
+
}
|
|
48
|
+
createRequest(resource, managedIdentityId) {
|
|
49
|
+
const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
|
|
50
|
+
request.headers[Constants.SERVICE_FABRIC_SECRET_HEADER_NAME] =
|
|
51
|
+
this.identityHeader;
|
|
52
|
+
request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
|
|
53
|
+
SERVICE_FABRIC_MSI_API_VERSION;
|
|
54
|
+
request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
55
|
+
resource;
|
|
56
|
+
if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
57
|
+
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
58
|
+
}
|
|
59
|
+
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
60
|
+
return request;
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
exports.ServiceFabric = ServiceFabric;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { INetworkModule, Logger } from "@azure/msal-common";
|
|
2
|
-
import { ManagedIdentityId } from "../../config/ManagedIdentityId";
|
|
3
|
-
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
|
|
4
|
-
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
|
|
5
|
-
import { NodeStorage } from "../../cache/NodeStorage";
|
|
6
|
-
import { CryptoProvider } from "../../crypto/CryptoProvider";
|
|
7
|
-
/**
|
|
8
|
-
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
9
|
-
*/
|
|
10
|
-
export declare class ServiceFabric extends BaseManagedIdentitySource {
|
|
11
|
-
private identityEndpoint;
|
|
12
|
-
private identityHeader;
|
|
13
|
-
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string, identityHeader: string);
|
|
14
|
-
static getEnvironmentVariables(): Array<string | undefined>;
|
|
15
|
-
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, managedIdentityId: ManagedIdentityId): ServiceFabric | null;
|
|
16
|
-
createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
17
|
-
}
|
|
1
|
+
import { INetworkModule, Logger } from "@azure/msal-common";
|
|
2
|
+
import { ManagedIdentityId } from "../../config/ManagedIdentityId";
|
|
3
|
+
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
|
|
4
|
+
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
|
|
5
|
+
import { NodeStorage } from "../../cache/NodeStorage";
|
|
6
|
+
import { CryptoProvider } from "../../crypto/CryptoProvider";
|
|
7
|
+
/**
|
|
8
|
+
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
9
|
+
*/
|
|
10
|
+
export declare class ServiceFabric extends BaseManagedIdentitySource {
|
|
11
|
+
private identityEndpoint;
|
|
12
|
+
private identityHeader;
|
|
13
|
+
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string, identityHeader: string);
|
|
14
|
+
static getEnvironmentVariables(): Array<string | undefined>;
|
|
15
|
+
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, managedIdentityId: ManagedIdentityId): ServiceFabric | null;
|
|
16
|
+
createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=ServiceFabric.d.ts.map
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
/*! @azure/msal-node v2.
|
|
1
|
+
/*! @azure/msal-node v2.13.1 2024-08-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { ManagedIdentityRequestParameters } from '../../config/ManagedIdentityRequestParameters.mjs';
|
|
4
4
|
import { BaseManagedIdentitySource } from './BaseManagedIdentitySource.mjs';
|
|
5
5
|
import { ManagedIdentityEnvironmentVariableNames, ManagedIdentitySourceNames, ManagedIdentityIdType, SERVICE_FABRIC_SECRET_HEADER_NAME, API_VERSION_QUERY_PARAMETER_NAME, RESOURCE_BODY_OR_QUERY_PARAMETER_NAME, HttpMethod } from '../../utils/Constants.mjs';
|
|
6
6
|
|
|
7
|
-
/*
|
|
8
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
-
* Licensed under the MIT License.
|
|
10
|
-
*/
|
|
11
|
-
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
12
|
-
const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
13
|
-
/**
|
|
14
|
-
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
15
|
-
*/
|
|
16
|
-
class ServiceFabric extends BaseManagedIdentitySource {
|
|
17
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
18
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
19
|
-
this.identityEndpoint = identityEndpoint;
|
|
20
|
-
this.identityHeader = identityHeader;
|
|
21
|
-
}
|
|
22
|
-
static getEnvironmentVariables() {
|
|
23
|
-
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
24
|
-
const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
25
|
-
const identityServerThumbprint = process.env[ManagedIdentityEnvironmentVariableNames
|
|
26
|
-
.IDENTITY_SERVER_THUMBPRINT];
|
|
27
|
-
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
28
|
-
}
|
|
29
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
30
|
-
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
31
|
-
/*
|
|
32
|
-
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
33
|
-
* environment variables are undefined, this MSI provider is unavailable.
|
|
34
|
-
*/
|
|
35
|
-
if (!identityEndpoint || !identityHeader || !identityServerThumbprint) {
|
|
36
|
-
logger.info(`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity is unavailable because one or all of the '${ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}', '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' or '${ManagedIdentityEnvironmentVariableNames.IDENTITY_SERVER_THUMBPRINT}' environment variables are not defined.`);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const validatedIdentityEndpoint = ServiceFabric.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, ManagedIdentitySourceNames.SERVICE_FABRIC, logger);
|
|
40
|
-
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity.`);
|
|
41
|
-
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
42
|
-
logger.warning(`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} user assigned managed identity is configured in the cluster, not during runtime. See also: https://learn.microsoft.com/en-us/azure/service-fabric/configure-existing-cluster-enable-managed-identity-token-service.`);
|
|
43
|
-
}
|
|
44
|
-
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
45
|
-
}
|
|
46
|
-
createRequest(resource, managedIdentityId) {
|
|
47
|
-
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
48
|
-
request.headers[SERVICE_FABRIC_SECRET_HEADER_NAME] =
|
|
49
|
-
this.identityHeader;
|
|
50
|
-
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
51
|
-
SERVICE_FABRIC_MSI_API_VERSION;
|
|
52
|
-
request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
53
|
-
resource;
|
|
54
|
-
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
55
|
-
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
56
|
-
}
|
|
57
|
-
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
58
|
-
return request;
|
|
59
|
-
}
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
* Licensed under the MIT License.
|
|
10
|
+
*/
|
|
11
|
+
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
12
|
+
const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
13
|
+
/**
|
|
14
|
+
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
15
|
+
*/
|
|
16
|
+
class ServiceFabric extends BaseManagedIdentitySource {
|
|
17
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
18
|
+
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
19
|
+
this.identityEndpoint = identityEndpoint;
|
|
20
|
+
this.identityHeader = identityHeader;
|
|
21
|
+
}
|
|
22
|
+
static getEnvironmentVariables() {
|
|
23
|
+
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
24
|
+
const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
25
|
+
const identityServerThumbprint = process.env[ManagedIdentityEnvironmentVariableNames
|
|
26
|
+
.IDENTITY_SERVER_THUMBPRINT];
|
|
27
|
+
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
28
|
+
}
|
|
29
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
30
|
+
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
31
|
+
/*
|
|
32
|
+
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
33
|
+
* environment variables are undefined, this MSI provider is unavailable.
|
|
34
|
+
*/
|
|
35
|
+
if (!identityEndpoint || !identityHeader || !identityServerThumbprint) {
|
|
36
|
+
logger.info(`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity is unavailable because one or all of the '${ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}', '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' or '${ManagedIdentityEnvironmentVariableNames.IDENTITY_SERVER_THUMBPRINT}' environment variables are not defined.`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const validatedIdentityEndpoint = ServiceFabric.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, ManagedIdentitySourceNames.SERVICE_FABRIC, logger);
|
|
40
|
+
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity.`);
|
|
41
|
+
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
42
|
+
logger.warning(`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} user assigned managed identity is configured in the cluster, not during runtime. See also: https://learn.microsoft.com/en-us/azure/service-fabric/configure-existing-cluster-enable-managed-identity-token-service.`);
|
|
43
|
+
}
|
|
44
|
+
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
45
|
+
}
|
|
46
|
+
createRequest(resource, managedIdentityId) {
|
|
47
|
+
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
48
|
+
request.headers[SERVICE_FABRIC_SECRET_HEADER_NAME] =
|
|
49
|
+
this.identityHeader;
|
|
50
|
+
request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
|
|
51
|
+
SERVICE_FABRIC_MSI_API_VERSION;
|
|
52
|
+
request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
|
|
53
|
+
resource;
|
|
54
|
+
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
55
|
+
request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
|
|
56
|
+
}
|
|
57
|
+
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
58
|
+
return request;
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export { ServiceFabric };
|