attempt a fix at node auth
This commit is contained in:
Родитель
ab69a7ad16
Коммит
f0d64def58
|
@ -12,7 +12,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ms_rest_js_1 = require("ms-rest-js");
|
||||
const ms_rest_azure_env_1 = require("ms-rest-azure-env");
|
||||
const authConstants_1 = require("../util/authConstants");
|
||||
const adal = require("adal-node");
|
||||
class TokenCredentialsBase {
|
||||
constructor(clientId, domain, tokenAudience, environment = ms_rest_azure_env_1.AzureEnvironment.Azure, tokenCache = new adal.MemoryCache()) {
|
||||
|
@ -27,7 +26,7 @@ class TokenCredentialsBase {
|
|||
if (!Boolean(domain) || typeof domain.valueOf() !== "string") {
|
||||
throw new Error("domain must be a non empty string.");
|
||||
}
|
||||
if (this.tokenAudience === authConstants_1.TokenAudience.graph) {
|
||||
if (this.tokenAudience === "graph") {
|
||||
this.isGraphContext = true;
|
||||
if (this.domain.toLowerCase() === "common") {
|
||||
throw new Error(`${"If the tokenAudience is specified as \"graph\" then \"domain\" cannot be defaulted to \"commmon\" tenant.\
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"tokenCredentialsBase.js","sourceRoot":"","sources":["../../../lib/credentials/tokenCredentialsBase.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;AAE/F,2CAAuE;AACvE,yDAAqD;AACrD,yDAAsD;AACtD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAQlC;IAIE,YACkB,QAAgB,EACzB,MAAc,EACL,aAA6B,EAC7B,cAAc,oCAAgB,CAAC,KAAK,EAC7C,aAAkB,IAAI,IAAI,CAAC,WAAW,EAAE;QAJ/B,aAAQ,GAAR,QAAQ,CAAQ;QACzB,WAAM,GAAN,MAAM,CAAQ;QACL,kBAAa,GAAb,aAAa,CAAgB;QAC7B,gBAAW,GAAX,WAAW,CAAyB;QAC7C,eAAU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AAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAY,EAAE,aAA4B,EAAE,EAAE;gBAC9G,IAAI,KAAK,EAAE;oBACT,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;iBACtB;gBACD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAUD;;;;;;OAMG;IACU,WAAW,CAAC,WAAwB;;YAC/C,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAe,CAAC,eAAe,CAAC,aAAa,EAAE,GAAG,aAAa,CAAC,SAAS,IAAI,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;YAClI,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;KAAA;CACF;AA5ED,oDA4EC"}
|
|
@ -74,7 +74,7 @@ function withUsernamePasswordWithAuthResponse(username, password, options) {
|
|||
// The token cache gets propulated for all the tenants as a part of building the tenantList.
|
||||
tenantList = yield subscriptionUtils_1.buildTenantList(creds);
|
||||
// We dont need to get the subscriptionList if the tokenAudience is graph as graph clients are tenant based.
|
||||
if (!(options.tokenAudience && options.tokenAudience === authConstants_1.TokenAudience.graph)) {
|
||||
if (!(options.tokenAudience && options.tokenAudience === "graph")) {
|
||||
subscriptionList = yield subscriptionUtils_1.getSubscriptionsFromTenants(creds, tenantList);
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ function withServicePrincipalSecretWithAuthResponse(clientId, secret, domain, op
|
|||
creds = new applicationTokenCredentials_1.ApplicationTokenCredentials(clientId, domain, secret, options.tokenAudience, options.environment);
|
||||
yield creds.getToken();
|
||||
// We dont need to get the subscriptionList if the tokenAudience is graph as graph clients are tenant based.
|
||||
if (!(options.tokenAudience && options.tokenAudience === authConstants_1.TokenAudience.graph)) {
|
||||
if (!(options.tokenAudience && options.tokenAudience === "graph")) {
|
||||
subscriptionList = yield subscriptionUtils_1.getSubscriptionsFromTenants(creds, [domain]);
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ function withInteractiveWithAuthResponse(options) {
|
|||
});
|
||||
});
|
||||
function getSubscriptions(creds, tenants) {
|
||||
if (!(interactiveOptions.tokenAudience && interactiveOptions.tokenAudience === authConstants_1.TokenAudience.graph)) {
|
||||
if (!(interactiveOptions.tokenAudience && interactiveOptions.tokenAudience === "graph")) {
|
||||
return subscriptionUtils_1.getSubscriptionsFromTenants(creds, tenants);
|
||||
}
|
||||
return Promise.resolve([]);
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -14,7 +14,6 @@ const msiTokenCredentials_1 = require("./credentials/msiTokenCredentials");
|
|||
exports.MSITokenCredentials = msiTokenCredentials_1.MSITokenCredentials;
|
||||
const authConstants_1 = require("./util/authConstants");
|
||||
exports.AuthConstants = authConstants_1.AuthConstants;
|
||||
exports.TokenAudience = authConstants_1.TokenAudience;
|
||||
const login_1 = require("./login");
|
||||
exports.interactiveLogin = login_1.interactive;
|
||||
exports.loginWithAuthFile = login_1.withAuthFile;
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"msRestNodeAuth.js","sourceRoot":"","sources":["../../lib/msRestNodeAuth.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,6EAAyF;AAgBvF,+BAhBO,2CAAoB,CAgBP;AAftB,2FAAwF;AAejD,sCAf9B,yDAA2B,CAe8B;AAdlE,iFAA8E;AAcV,iCAd3D,+CAAsB,CAc2D;AAb1F,6EAA0E;AAcxE,+BAdO,2CAAoB,CAcP;AAbtB,2EAA0F;AAalE,8BAbf,yCAAmB,CAae;AAZ3C,wDAAoE;AAYL,wBAZtD,6BAAa,CAYsD;AAAE,wBAZtD,6BAAa,CAYsD;AAV3F,mCAMiB;AAOA,2BAVf,mBAAW,CAUoB;AAMf,4BAhBH,oBAAY,CAgBQ;AACD,4CAjBL,oCAA4B,CAiBU;AAN9B,2CAXsB,uCAA+B,CAWrB;AAOxD,uBAjBX,eAAO,CAiBgB;AAJO,0CAbrB,kCAA0B,CAa0B;AACf,0DAdT,kDAA0C,CAcc;AAHrE,oCAVxB,4BAAoB,CAU6B;AACT,oDAXlB,4CAAoC,CAWuB"}
|
||||
{"version":3,"file":"msRestNodeAuth.js","sourceRoot":"","sources":["../../lib/msRestNodeAuth.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,6EAAyF;AAgBvF,+BAhBO,2CAAoB,CAgBP;AAftB,2FAAwF;AAejD,sCAf9B,yDAA2B,CAe8B;AAdlE,iFAA8E;AAcV,iCAd3D,+CAAsB,CAc2D;AAb1F,6EAA0E;AAcxE,+BAdO,2CAAoB,CAcP;AAbtB,2EAA0F;AAalE,8BAbf,yCAAmB,CAae;AAZ3C,wDAAoE;AAYL,wBAZtD,6BAAa,CAYsD;AAV5E,mCAMiB;AAOA,2BAVf,mBAAW,CAUoB;AAMf,4BAhBH,oBAAY,CAgBQ;AACD,4CAjBL,oCAA4B,CAiBU;AAN9B,2CAXsB,uCAA+B,CAWrB;AAOxD,uBAjBX,eAAO,CAiBgB;AAJO,0CAbrB,kCAA0B,CAa0B;AACf,0DAdT,kDAA0C,CAcc;AAHrE,oCAVxB,4BAAoB,CAU6B;AACT,oDAXlB,4CAAoC,CAWuB"}
|
|
@ -9,8 +9,4 @@ exports.AuthConstants = {
|
|||
"DEFAULT_LANGUAGE": "en-us",
|
||||
"AZURE_AUTH_LOCATION": "AZURE_AUTH_LOCATION"
|
||||
};
|
||||
var TokenAudience;
|
||||
(function (TokenAudience) {
|
||||
TokenAudience[TokenAudience["graph"] = 0] = "graph";
|
||||
})(TokenAudience = exports.TokenAudience || (exports.TokenAudience = {}));
|
||||
//# sourceMappingURL=authConstants.js.map
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"authConstants.js","sourceRoot":"","sources":["../../../lib/util/authConstants.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAElF,QAAA,aAAa,GAAG;IAC3B,mBAAmB,EAAE,QAAQ;IAC7B,wBAAwB,EAAE,sCAAsC;IAChE,oBAAoB,EAAE,oBAAoB;IAC1C,kBAAkB,EAAE,OAAO;IAC3B,qBAAqB,EAAE,qBAAqB;CAC7C,CAAC;AAEF,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,mDAAK,CAAA;AACP,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB"}
|
||||
{"version":3,"file":"authConstants.js","sourceRoot":"","sources":["../../../lib/util/authConstants.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAElF,QAAA,aAAa,GAAG;IAC3B,mBAAmB,EAAE,QAAQ;IAC7B,wBAAwB,EAAE,sCAAsC;IAChE,oBAAoB,EAAE,oBAAoB;IAC1C,kBAAkB,EAAE,OAAO;IAC3B,qBAAqB,EAAE,qBAAqB;CAC7C,CAAC"}
|
|
@ -31,7 +31,7 @@ export abstract class TokenCredentialsBase {
|
|||
throw new Error("domain must be a non empty string.");
|
||||
}
|
||||
|
||||
if (this.tokenAudience === TokenAudience.graph) {
|
||||
if (this.tokenAudience === "graph") {
|
||||
this.isGraphContext = true;
|
||||
|
||||
if (this.domain.toLowerCase() === "common") {
|
||||
|
@ -47,10 +47,14 @@ export abstract class TokenCredentialsBase {
|
|||
}
|
||||
|
||||
protected getActiveDirectoryResourceId(): string {
|
||||
const resource = this.isGraphContext
|
||||
let resource = this.isGraphContext
|
||||
? this.environment.activeDirectoryGraphResourceId
|
||||
: this.environment.activeDirectoryResourceId;
|
||||
|
||||
if (this.tokenAudience) {
|
||||
resource = this.tokenAudience;
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ export async function withUsernamePasswordWithAuthResponse(username: string, pas
|
|||
// The token cache gets propulated for all the tenants as a part of building the tenantList.
|
||||
tenantList = await buildTenantList(creds);
|
||||
// We dont need to get the subscriptionList if the tokenAudience is graph as graph clients are tenant based.
|
||||
if (!(options.tokenAudience && options.tokenAudience === TokenAudience.graph)) {
|
||||
if (!(options.tokenAudience && options.tokenAudience === "graph")) {
|
||||
subscriptionList = await getSubscriptionsFromTenants(creds, tenantList);
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -205,7 +205,7 @@ export async function withServicePrincipalSecretWithAuthResponse(clientId: strin
|
|||
creds = new ApplicationTokenCredentials(clientId, domain, secret, options.tokenAudience, options.environment);
|
||||
await creds.getToken();
|
||||
// We dont need to get the subscriptionList if the tokenAudience is graph as graph clients are tenant based.
|
||||
if (!(options.tokenAudience && options.tokenAudience === TokenAudience.graph)) {
|
||||
if (!(options.tokenAudience && options.tokenAudience === "graph")) {
|
||||
subscriptionList = await getSubscriptionsFromTenants(creds, [domain]);
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -437,7 +437,7 @@ export async function withInteractiveWithAuthResponse(options?: InteractiveLogin
|
|||
});
|
||||
|
||||
function getSubscriptions(creds: DeviceTokenCredentials, tenants: string[]): Promise<LinkedSubscription[]> {
|
||||
if (!(interactiveOptions.tokenAudience && interactiveOptions.tokenAudience === TokenAudience.graph)) {
|
||||
if (!(interactiveOptions.tokenAudience && interactiveOptions.tokenAudience === "graph")) {
|
||||
return getSubscriptionsFromTenants(creds, tenants);
|
||||
}
|
||||
return Promise.resolve(([] as any[]));
|
||||
|
|
|
@ -9,6 +9,4 @@ export const AuthConstants = {
|
|||
"AZURE_AUTH_LOCATION": "AZURE_AUTH_LOCATION"
|
||||
};
|
||||
|
||||
export enum TokenAudience {
|
||||
graph,
|
||||
}
|
||||
export type TokenAudience = "graph" | string;
|
|
@ -1,5 +1,4 @@
|
|||
import { WebResource } from "ms-rest-js";
|
||||
import { TokenAudience } from "../util/authConstants";
|
||||
export interface TokenResponse {
|
||||
readonly tokenType: string;
|
||||
readonly accessToken: string;
|
||||
|
@ -8,7 +7,7 @@ export interface TokenResponse {
|
|||
export declare abstract class TokenCredentialsBase {
|
||||
readonly clientId: string;
|
||||
domain: string;
|
||||
readonly tokenAudience?: TokenAudience | undefined;
|
||||
readonly tokenAudience?: string | undefined;
|
||||
readonly environment: {
|
||||
name: string;
|
||||
portalUrl: string;
|
||||
|
@ -31,7 +30,7 @@ export declare abstract class TokenCredentialsBase {
|
|||
tokenCache: any;
|
||||
protected readonly isGraphContext: boolean;
|
||||
protected readonly authContext: any;
|
||||
constructor(clientId: string, domain: string, tokenAudience?: TokenAudience | undefined, environment?: {
|
||||
constructor(clientId: string, domain: string, tokenAudience?: string | undefined, environment?: {
|
||||
name: string;
|
||||
portalUrl: string;
|
||||
publishingProfileUrl: string;
|
||||
|
|
|
@ -5,6 +5,4 @@ export declare const AuthConstants: {
|
|||
"DEFAULT_LANGUAGE": string;
|
||||
"AZURE_AUTH_LOCATION": string;
|
||||
};
|
||||
export declare enum TokenAudience {
|
||||
graph = 0
|
||||
}
|
||||
export declare type TokenAudience = "graph" | string;
|
||||
|
|
Загрузка…
Ссылка в новой задаче