Skip to content

Handle ci/cd job token #846

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,25 @@ export default async (pluginConfig, context) => {
}

if (gitlabToken && projectPath) {
let tokenHeader;
let projectAccess;
let groupAccess;

logger.log("Verify GitLab authentication (%s)", gitlabApiUrl);

switch(true) {
case str.startsWith("glcbt-"):
tokenHeader = "JOB-TOKEN"
default:
tokenHeader = "PRIVATE-TOKEN"
}

Choose a reason for hiding this comment

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

Suggested change
switch(true) {
case str.startsWith("glcbt-"):
tokenHeader = "JOB-TOKEN"
default:
tokenHeader = "PRIVATE-TOKEN"
}
switch(gitlabToken) {
case gitlabToken.startsWith("glcbt-"):
tokenHeader = "JOB-TOKEN"
default:
tokenHeader = "PRIVATE-TOKEN"
}

@AlexandreEXFO - you need to switch the gitlabToken here.

Copy link
Author

Choose a reason for hiding this comment

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

@toms-place: Yes, I'm a bit rusty on Javascript and have found several other places where the header should also be handled.


try {
({
permissions: { project_access: projectAccess, group_access: groupAccess },
} = await got
.get(projectApiUrl, {
headers: { "PRIVATE-TOKEN": gitlabToken },
headers: { tokenHeader: gitlabToken },
...proxy,
})
.json());
Expand Down