mirror of
https://github.com/azure/login.git
synced 2026-06-08 09:17:07 +00:00
Compare commits
1 commit
master
...
master-tok
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3d59c65b2 |
2 changed files with 18 additions and 0 deletions
10
lib/main.js
10
lib/main.js
|
|
@ -140,6 +140,8 @@ function main() {
|
||||||
if (!!federatedToken) {
|
if (!!federatedToken) {
|
||||||
if (environment != "azurecloud")
|
if (environment != "azurecloud")
|
||||||
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
|
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
|
||||||
|
let [issuer, subjectClaim] = yield jwtParser(federatedToken);
|
||||||
|
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Could not get ID token for authentication.");
|
throw new Error("Could not get ID token for authentication.");
|
||||||
|
|
@ -230,4 +232,12 @@ function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
||||||
yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function jwtParser(federatedToken) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let tokenPayload = federatedToken.split('.')[1];
|
||||||
|
let bufferObj = Buffer.from(tokenPayload, "base64");
|
||||||
|
let decodedPayload = JSON.parse(bufferObj.toString("utf8"));
|
||||||
|
return [decodedPayload['iss'], decodedPayload['sub']];
|
||||||
|
});
|
||||||
|
}
|
||||||
main();
|
main();
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,8 @@ async function main() {
|
||||||
if (!!federatedToken) {
|
if (!!federatedToken) {
|
||||||
if (environment != "azurecloud")
|
if (environment != "azurecloud")
|
||||||
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
|
throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
|
||||||
|
let [issuer, subjectClaim] = await jwtParser(federatedToken);
|
||||||
|
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Could not get ID token for authentication.");
|
throw new Error("Could not get ID token for authentication.");
|
||||||
|
|
@ -227,4 +229,10 @@ async function executeAzCliCommand(
|
||||||
execOptions.silent = !!silent;
|
execOptions.silent = !!silent;
|
||||||
await exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
await exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
||||||
}
|
}
|
||||||
|
async function jwtParser(federatedToken: string) {
|
||||||
|
let tokenPayload = federatedToken.split('.')[1];
|
||||||
|
let bufferObj = Buffer.from(tokenPayload, "base64");
|
||||||
|
let decodedPayload = JSON.parse(bufferObj.toString("utf8"));
|
||||||
|
return [decodedPayload['iss'], decodedPayload['sub']];
|
||||||
|
}
|
||||||
main();
|
main();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue