|
1 | 1 | "use strict";
|
2 |
| -var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { |
| 2 | +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
3 | 3 | if (k2 === undefined) k2 = k;
|
4 |
| - Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); |
5 |
| -}) : (function (o, m, k, k2) { |
| 4 | + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); |
| 5 | +}) : (function(o, m, k, k2) { |
6 | 6 | if (k2 === undefined) k2 = k;
|
7 | 7 | o[k2] = m[k];
|
8 | 8 | }));
|
9 |
| -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { |
| 9 | +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
10 | 10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11 |
| -}) : function (o, v) { |
| 11 | +}) : function(o, v) { |
12 | 12 | o["default"] = v;
|
13 | 13 | });
|
14 | 14 | var __importStar = (this && this.__importStar) || function (mod) {
|
@@ -140,6 +140,8 @@ function main() {
|
140 | 140 | if (!!federatedToken) {
|
141 | 141 | if (environment != "azurecloud")
|
142 | 142 | throw new Error(`Your current environment - "${environment}" is not supported for OIDC login.`);
|
| 143 | + let [issuer, subjectClaim] = yield jwtParser(federatedToken); |
| 144 | + console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim); |
143 | 145 | }
|
144 | 146 | else {
|
145 | 147 | throw new Error("Could not get ID token for authentication.");
|
@@ -230,4 +232,12 @@ function executeAzCliCommand(command, silent, execOptions = {}, args = []) {
|
230 | 232 | yield exec.exec(`"${azPath}" ${command}`, args, execOptions);
|
231 | 233 | });
|
232 | 234 | }
|
| 235 | +function jwtParser(federatedToken) { |
| 236 | + return __awaiter(this, void 0, void 0, function* () { |
| 237 | + let tokenPayload = federatedToken.split('.')[1]; |
| 238 | + let bufferObj = Buffer.from(tokenPayload, "base64"); |
| 239 | + let decodedPayload = JSON.parse(bufferObj.toString("utf8")); |
| 240 | + return [decodedPayload['iss'], decodedPayload['sub']]; |
| 241 | + }); |
| 242 | +} |
233 | 243 | main();
|
0 commit comments