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

Support json keys as credentials to access private registries #8938

Closed
princerachit opened this issue Mar 23, 2022 · 5 comments · Fixed by #10031
Closed

Support json keys as credentials to access private registries #8938

princerachit opened this issue Mar 23, 2022 · 5 comments · Fixed by #10031
Assignees
Labels
team: workspace Issue belongs to the Workspace team

Comments

@princerachit
Copy link
Contributor

princerachit commented Mar 23, 2022

Is your feature request related to a problem? Please describe

As a gitpod user who wants to use private registries to pull images, I want to use my json key instead of plain username:password to configure registry access. i.e. my password could be a json e.g. service account key of google cloud.

With #8550 a support for using username:password was added but it fails when the auth config passed is built using a json key e.g.

echo $key | docker login -u _json_key --password-stdin

Describe alternatives you've considered

NA

Additional context

Failure

image

Private image

europe-docker.pkg.dev/prince-tf-experiments/dazzle/workspace-images:base
@princerachit princerachit added the team: workspace Issue belongs to the Workspace team label Mar 23, 2022
@cooperbenson-qz
Copy link

I noticed that there's a new feature in GAR that allows you to pass the JSON SA key as a base64 encoded string when using the username _json_key_base64 (according to the docs).

@kylos101
Copy link
Contributor

kylos101 commented Apr 8, 2022

@princerachit can you add this to our inbox too?

@princerachit
Copy link
Contributor Author

The issue is due to the way we decode and split the auth string in our code. In the image-builder-mk3 we split by colon which results the json to get split into multiple strings.

segs := strings.Split(string(dec), ":")
if len(segs) == 2 {
res.Username = segs[0]
res.Password = segs[1]
}
}

Due to the check at line 211 the password is never set. This result in the auth string being used for bearer token authentication method instead of basic authentication which results in a 401 error.

When I change above lines to the following to check if this string can be split into at least two string and then treat segs[1] as password. image-builder-mk3 succeeds in creation of imagebuild pods.

	if err == nil {
		segs := strings.SplitN(string(dec), ":", 2)
		if len(segs) == 2 {
			res.Username = segs[0]
			res.Password = segs[1]
		}
	}

While creating the imagebuild pods mk3 sets the WORKSPACEKIT_BOBPROXY_ADDITIONALAUTH env variable which contains both user passs as well as the auth string.

Name: "WORKSPACEKIT_BOBPROXY_ADDITIONALAUTH",
Value: string(additionalAuth),

I suspect our credentials setting login involving above env var is causing an issue where it does not use the user and password but instead tries to use auth string for bearer token authentication.

I will debug this further. The telepresence script is broken for image builder. Maybe fixing it then debugging is the right way to proceed

@princerachit princerachit moved this from Scheduled to In Progress in 🌌 Workspace Team May 16, 2022
@princerachit
Copy link
Contributor Author

princerachit commented May 17, 2022

@princerachit
Copy link
Contributor Author

I found another bug with this implementation and have created a separate issue #10089

Repository owner moved this from In Progress to Done in 🌌 Workspace Team May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team: workspace Issue belongs to the Workspace team
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants