mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
add js build files
This commit is contained in:
@@ -25,21 +25,14 @@ const PowerShellToolRunner_1 = __importDefault(require("./Utilities/PowerShellTo
|
|||||||
const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder"));
|
const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder"));
|
||||||
const Constants_1 = __importDefault(require("./Constants"));
|
const Constants_1 = __importDefault(require("./Constants"));
|
||||||
class ServicePrincipalLogin {
|
class ServicePrincipalLogin {
|
||||||
<<<<<<< HEAD
|
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin, environment, resourceManagerEndpointUrl) {
|
||||||
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, environment, resourceManagerEndpointUrl) {
|
|
||||||
=======
|
|
||||||
constructor(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin) {
|
|
||||||
>>>>>>> master
|
|
||||||
this.servicePrincipalId = servicePrincipalId;
|
this.servicePrincipalId = servicePrincipalId;
|
||||||
this.servicePrincipalKey = servicePrincipalKey;
|
this.servicePrincipalKey = servicePrincipalKey;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
this.subscriptionId = subscriptionId;
|
this.subscriptionId = subscriptionId;
|
||||||
<<<<<<< HEAD
|
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.resourceManagerEndpointUrl = resourceManagerEndpointUrl;
|
this.resourceManagerEndpointUrl = resourceManagerEndpointUrl;
|
||||||
=======
|
|
||||||
this.allowNoSubscriptionsLogin = allowNoSubscriptionsLogin;
|
this.allowNoSubscriptionsLogin = allowNoSubscriptionsLogin;
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
initialize() {
|
initialize() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@@ -63,15 +56,10 @@ class ServicePrincipalLogin {
|
|||||||
servicePrincipalId: this.servicePrincipalId,
|
servicePrincipalId: this.servicePrincipalId,
|
||||||
servicePrincipalKey: this.servicePrincipalKey,
|
servicePrincipalKey: this.servicePrincipalKey,
|
||||||
subscriptionId: this.subscriptionId,
|
subscriptionId: this.subscriptionId,
|
||||||
<<<<<<< HEAD
|
|
||||||
environment: this.environment,
|
environment: this.environment,
|
||||||
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
||||||
resourceManagerEndpointUrl: this.resourceManagerEndpointUrl,
|
allowNoSubscriptionsLogin: this.allowNoSubscriptionsLogin,
|
||||||
=======
|
resourceManagerEndpointUrl: this.resourceManagerEndpointUrl
|
||||||
environment: ServicePrincipalLogin.environment,
|
|
||||||
scopeLevel: ServicePrincipalLogin.scopeLevel,
|
|
||||||
allowNoSubscriptionsLogin: this.allowNoSubscriptionsLogin
|
|
||||||
>>>>>>> master
|
|
||||||
};
|
};
|
||||||
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
|
||||||
yield PowerShellToolRunner_1.default.init();
|
yield PowerShellToolRunner_1.default.init();
|
||||||
|
|||||||
79
lib/main.js
79
lib/main.js
@@ -1,26 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
<<<<<<< HEAD
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
=======
|
|
||||||
>>>>>>> master
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -30,11 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
<<<<<<< HEAD
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const crypto = __importStar(require("crypto"));
|
|
||||||
=======
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -44,7 +17,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
>>>>>>> master
|
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const actions_secret_parser_1 = require("actions-secret-parser");
|
const actions_secret_parser_1 = require("actions-secret-parser");
|
||||||
@@ -57,21 +29,20 @@ function main() {
|
|||||||
try {
|
try {
|
||||||
// Set user agent variable
|
// Set user agent variable
|
||||||
var isAzCLISuccess = false;
|
var isAzCLISuccess = false;
|
||||||
<<<<<<< HEAD
|
|
||||||
let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex');
|
|
||||||
=======
|
|
||||||
let usrAgentRepo = `${process.env.GITHUB_REPOSITORY}`;
|
let usrAgentRepo = `${process.env.GITHUB_REPOSITORY}`;
|
||||||
>>>>>>> master
|
|
||||||
let actionName = 'AzureLogin';
|
let actionName = 'AzureLogin';
|
||||||
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
let azurePSHostEnv = (!!azPSHostEnv ? `${azPSHostEnv}+` : '') + `GITHUBACTIONS/${actionName}@v1_${usrAgentRepo}`;
|
||||||
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
|
||||||
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
|
||||||
azPath = yield io.which("az", true);
|
azPath = yield io.which("az", true);
|
||||||
<<<<<<< HEAD
|
let azureSupportedCloudName = new Set([
|
||||||
yield executeAzCliCommand("--version");
|
"azureusgovernment",
|
||||||
let azureSupportedCloudName = new Set(["azureusgovernment", "azurechinacloud", "azuregermancloud", "azurecloud", "azurestack"]);
|
"azurechinacloud",
|
||||||
=======
|
"azuregermancloud",
|
||||||
|
"azurecloud",
|
||||||
|
"azurestack"
|
||||||
|
]);
|
||||||
let output = "";
|
let output = "";
|
||||||
const execOptions = {
|
const execOptions = {
|
||||||
listeners: {
|
listeners: {
|
||||||
@@ -82,19 +53,21 @@ function main() {
|
|||||||
};
|
};
|
||||||
yield executeAzCliCommand("--version", true, execOptions);
|
yield executeAzCliCommand("--version", true, execOptions);
|
||||||
core.debug(`az cli version used:\n${output}`);
|
core.debug(`az cli version used:\n${output}`);
|
||||||
>>>>>>> master
|
|
||||||
let creds = core.getInput('creds', { required: true });
|
let creds = core.getInput('creds', { required: true });
|
||||||
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
|
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
|
||||||
let servicePrincipalId = secrets.getSecret("$.clientId", false);
|
let servicePrincipalId = secrets.getSecret("$.clientId", false);
|
||||||
let servicePrincipalKey = secrets.getSecret("$.clientSecret", true);
|
let servicePrincipalKey = secrets.getSecret("$.clientSecret", true);
|
||||||
let tenantId = secrets.getSecret("$.tenantId", false);
|
let tenantId = secrets.getSecret("$.tenantId", false);
|
||||||
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
|
||||||
<<<<<<< HEAD
|
|
||||||
let resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
let resourceManagerEndpointUrl = secrets.getSecret("$.resourceManagerEndpointUrl", false);
|
||||||
let environment = core.getInput("environment").toLowerCase();
|
let environment = core.getInput("environment").toLowerCase();
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !subscriptionId) {
|
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied.");
|
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
||||||
|
}
|
||||||
|
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
||||||
|
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
||||||
}
|
}
|
||||||
if (!azureSupportedCloudName.has(environment)) {
|
if (!azureSupportedCloudName.has(environment)) {
|
||||||
throw new Error("Unsupported value for environment is passed.The list of supported values for environment are ‘azureusgovernment', ‘azurechinacloud’, ‘azuregermancloud’, ‘azurecloud’ or ’azurestack’");
|
throw new Error("Unsupported value for environment is passed.The list of supported values for environment are ‘azureusgovernment', ‘azurechinacloud’, ‘azuregermancloud’, ‘azurecloud’ or ’azurestack’");
|
||||||
@@ -130,15 +103,6 @@ function main() {
|
|||||||
}
|
}
|
||||||
yield executeAzCliCommand(`cloud set -n "${environment}"`, false);
|
yield executeAzCliCommand(`cloud set -n "${environment}"`, false);
|
||||||
console.log(`Done setting cloud: "${environment}"`);
|
console.log(`Done setting cloud: "${environment}"`);
|
||||||
=======
|
|
||||||
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
|
|
||||||
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
|
|
||||||
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
|
|
||||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
|
|
||||||
}
|
|
||||||
if (!subscriptionId && !allowNoSubscriptionsLogin) {
|
|
||||||
throw new Error("Not all values are present in the creds object. Ensure subscriptionId is supplied.");
|
|
||||||
}
|
|
||||||
// Attempting Az cli login
|
// Attempting Az cli login
|
||||||
if (allowNoSubscriptionsLogin) {
|
if (allowNoSubscriptionsLogin) {
|
||||||
let args = [
|
let args = [
|
||||||
@@ -164,13 +128,11 @@ function main() {
|
|||||||
];
|
];
|
||||||
yield executeAzCliCommand(`account set`, true, {}, args);
|
yield executeAzCliCommand(`account set`, true, {}, args);
|
||||||
}
|
}
|
||||||
>>>>>>> master
|
|
||||||
isAzCLISuccess = true;
|
isAzCLISuccess = true;
|
||||||
if (enableAzPSSession) {
|
if (enableAzPSSession) {
|
||||||
// Attempting Az PS login
|
// Attempting Az PS login
|
||||||
console.log(`Running Azure PS Login`);
|
console.log(`Running Azure PS Login`);
|
||||||
<<<<<<< HEAD
|
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin, environment, resourceManagerEndpointUrl);
|
||||||
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, environment, resourceManagerEndpointUrl);
|
|
||||||
yield spnlogin.initialize();
|
yield spnlogin.initialize();
|
||||||
yield spnlogin.login();
|
yield spnlogin.login();
|
||||||
}
|
}
|
||||||
@@ -179,12 +141,6 @@ function main() {
|
|||||||
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||||
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
const spnlogin = new ServicePrincipalLogin_1.ServicePrincipalLogin(servicePrincipalId, servicePrincipalKey, tenantId, subscriptionId, allowNoSubscriptionsLogin);
|
|
||||||
yield spnlogin.initialize();
|
|
||||||
yield spnlogin.login();
|
|
||||||
}
|
|
||||||
>>>>>>> master
|
|
||||||
console.log("Login successful.");
|
console.log("Login successful.");
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -203,18 +159,11 @@ function main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
function executeAzCliCommand(command, silent) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield exec.exec(`"${azPath}" ${command}`, [], { silent: !!silent });
|
|
||||||
=======
|
|
||||||
function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
execOptions.silent = !!silent;
|
execOptions.silent = !!silent;
|
||||||
try {
|
try {
|
||||||
yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
||||||
>>>>>>> master
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user