Skip to content
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

Add the ability to provide a separate auth token vs. patcher update token #49

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

ceschae
Copy link
Contributor

@ceschae ceschae commented Nov 14, 2024

Description

Adds the ability to distinguish between the PAT used to download and run Gruntwork tools vs. the PAT used for patcher update, which includes write access to the customer repo.

Distinguishing the two PATs is a nice security feature, and allows for finer controls over access / better enforcement of the principle of least privilege

validation

@ceschae ceschae requested a review from ZachGoldberg November 14, 2024 21:07
@ceschae ceschae force-pushed the caitlin/update-token branch from 52d06af to a171338 Compare November 14, 2024 21:09
@ZachGoldberg ZachGoldberg changed the title add the ability to provide a separate auth token vs. patcher update token Add the ability to provide a separate auth token vs. patcher update token Nov 14, 2024
dist/index.js Outdated
@@ -13768,7 +13768,8 @@ async function validateAccessToPatcherCli(octokit) {
}
}
async function run() {
const token = core.getInput("github_token");
const githubToken = core.getInput("github_token");
var updateToken = core.getInput("update_token");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var updateToken = core.getInput("update_token");
const updateToken = core.getInput("update_token");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it won't let me overwrite it later, if i keep it as a const. this was the simplest way imo to keep back compatibility, but i'm open to other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general pattern would be something like

const token1 = getToken1();
const token2 = getToken2();
const theTokenToUse = token1 ? token1 : token2;

someplace_later_that_needs_token(theTokenToUse)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if you truly do need the value to change, use let instead of var. In only very very rare circumstances is var more correct than let in modern JS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the knowledge! i am a "can get by OK" type/coffee/javascript programmer. always grateful for the inside scoop!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. in javascript, token1 ? token1 : token2 and token1 ?? token2 return different values if token1 is empty string as opposed to nullish. my favorite programming language! /s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist/index.js Outdated Show resolved Hide resolved
dist/index.js Outdated
@@ -13768,7 +13768,8 @@ async function validateAccessToPatcherCli(octokit) {
}
}
async function run() {
const token = core.getInput("github_token");
const githubToken = core.getInput("github_token");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I might call this instead the "gruntwork token" or "gruntwork code access token"

ceschae and others added 2 commits November 14, 2024 13:15
Co-authored-by: Zach Goldberg <zach@gruntwork.io>
@ceschae ceschae force-pushed the caitlin/update-token branch from d56cefb to fc47115 Compare November 14, 2024 21:52
@ceschae ceschae merged commit b1d692e into main Nov 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants