-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support OIDC for sovereign clouds #321
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -95,7 +95,7 @@ async function main() { | |||||
throw new Error("Credentials are not passed for Login action."); | ||||||
} | ||||||
} | ||||||
//generic checks | ||||||
//generic checks | ||||||
//servicePrincipalKey is only required in non-oidc scenario. | ||||||
if (!servicePrincipalId || !tenantId || !(servicePrincipalKey || enableOIDC)) { | ||||||
throw new Error("Not all values are present in the credentials. Ensure clientId, clientSecret and tenantId are supplied."); | ||||||
|
@@ -110,19 +110,21 @@ async function main() { | |||||
// OIDC specific checks | ||||||
if (enableOIDC) { | ||||||
console.log('Using OIDC authentication...') | ||||||
try { | ||||||
//generating ID-token | ||||||
let audience = core.getInput('audience', { required: false }); | ||||||
//generating ID-token | ||||||
let audience = core.getInput('audience', { required: false }); | ||||||
try{ | ||||||
federatedToken = await core.getIDToken(audience); | ||||||
if (!!federatedToken) { | ||||||
if (environment != "azurecloud") | ||||||
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); | ||||||
} | ||||||
} | ||||||
catch (error) { | ||||||
core.error(`${error.message.split(':')[1]}. Please make sure to give write permissions to id-token in the workflow.`); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All string operations should be accompanied by an example. Otherwise, it will be difficult for future readers to understand. |
||||||
core.error(`Please make sure to give write permissions to id-token in the workflow.`); | ||||||
throw error; | ||||||
} | ||||||
if (!!federatedToken) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Under what circumstances can |
||||||
let [issuer, subjectClaim] = await jwtParser(federatedToken); | ||||||
console.log("Federated token details: \n issuer - " + issuer + " \n subject claim - " + subjectClaim); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing spaces before an
Suggested change
|
||||||
} | ||||||
else{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Suggested change
|
||||||
throw new Error("Failed to fetch federated token."); | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style is important.
Read more from https://www.bing.com/search?q=why+is+code+style+important