Compare commits

...

2 Commits

Author SHA1 Message Date
Balaga Gayatri
92a5484dfa [BUG FIX] Version pattern quickfix releases (#245)
* Update Constants.js

* Update Constants.ts
2022-09-09 16:39:37 +05:30
Balaga Gayatri
24848bc889 Error handling for token permissions (#235) 2022-06-21 16:44:24 +05:30
5 changed files with 28 additions and 24 deletions

View File

@@ -34,5 +34,5 @@ branding:
icon: 'login.svg' icon: 'login.svg'
color: 'blue' color: 'blue'
runs: runs:
using: 'node12' using: 'node16'
main: 'lib/main.js' main: 'lib/main.js'

View File

@@ -5,7 +5,7 @@ class Constants {
exports.default = Constants; exports.default = Constants;
Constants.prefix = "az_"; Constants.prefix = "az_";
Constants.moduleName = "Az.Accounts"; Constants.moduleName = "Az.Accounts";
Constants.versionPattern = /[0-9]\.[0-9]\.[0-9]/; Constants.versionPattern = /[0-9]+\.[0-9]+\.[0-9]+/;
Constants.AzureCloud = "AzureCloud"; Constants.AzureCloud = "AzureCloud";
Constants.Subscription = "Subscription"; Constants.Subscription = "Subscription";
Constants.ServicePrincipal = "ServicePrincipal"; Constants.ServicePrincipal = "ServicePrincipal";

View File

@@ -132,17 +132,19 @@ function main() {
// OIDC specific checks // OIDC specific checks
if (enableOIDC) { if (enableOIDC) {
console.log('Using OIDC authentication...'); console.log('Using OIDC authentication...');
//generating ID-token try {
let audience = core.getInput('audience', { required: false }); //generating ID-token
federatedToken = yield core.getIDToken(audience); let audience = core.getInput('audience', { required: false });
if (!!federatedToken) { federatedToken = yield core.getIDToken(audience);
if (environment != "azurecloud") if (!!federatedToken) {
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`); if (environment != "azurecloud")
let [issuer, subjectClaim] = yield jwtParser(federatedToken); throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim); let [issuer, subjectClaim] = yield jwtParser(federatedToken);
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim);
}
} }
else { catch (error) {
throw new Error("Could not get ID token for authentication."); core.error(`${error.message.split(':')[1]}. Please make sure to give write permissions to id-token in the workflow.`);
} }
} }
// Attempting Az cli login // Attempting Az cli login

View File

@@ -1,7 +1,7 @@
export default class Constants { export default class Constants {
static readonly prefix: string = "az_"; static readonly prefix: string = "az_";
static readonly moduleName: string = "Az.Accounts"; static readonly moduleName: string = "Az.Accounts";
static readonly versionPattern = /[0-9]\.[0-9]\.[0-9]/; static readonly versionPattern = /[0-9]+\.[0-9]+\.[0-9]+/;
static readonly AzureCloud: string = "AzureCloud"; static readonly AzureCloud: string = "AzureCloud";
static readonly Subscription: string = "Subscription"; static readonly Subscription: string = "Subscription";

View File

@@ -110,17 +110,19 @@ async function main() {
// OIDC specific checks // OIDC specific checks
if (enableOIDC) { if (enableOIDC) {
console.log('Using OIDC authentication...') console.log('Using OIDC authentication...')
//generating ID-token try {
let audience = core.getInput('audience', { required: false }); //generating ID-token
federatedToken = await core.getIDToken(audience); let audience = core.getInput('audience', { required: false });
if (!!federatedToken) { federatedToken = await core.getIDToken(audience);
if (environment != "azurecloud") if (!!federatedToken) {
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`); if (environment != "azurecloud")
let [issuer, subjectClaim] = await jwtParser(federatedToken); throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim); let [issuer, subjectClaim] = await jwtParser(federatedToken);
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim);
}
} }
else { catch (error) {
throw new Error("Could not get ID token for authentication."); core.error(`${error.message.split(':')[1]}. Please make sure to give write permissions to id-token in the workflow.`);
} }
} }