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

crane: fails to load URL-sourced environment credentials #1886

Open
joaodrp opened this issue Mar 1, 2024 · 0 comments
Open

crane: fails to load URL-sourced environment credentials #1886

joaodrp opened this issue Mar 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@joaodrp
Copy link

joaodrp commented Mar 1, 2024

Describe the bug

I'm testing a workload identity federation setup from GitLab. crane seems to fail to identity environment credentials while the gcloud CLI succeeds. This behaviour seems to go against what was described in #1496 (comment).

I'm setting both CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE and GOOGLE_APPLICATION_CREDENTIALS environment variables to the path of a JSON file with the following content:

{
  "type": "external_account",
  "audience": "//iam.googleapis.com/projects/604150606412/locations/global/workloadIdentityPools/issue-reproduce/providers/issue-reproduce",
  "token_url": "https://sts.googleapis.com/v1/token",
  "subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
  "credential_source": {
    "url": "https://auth.gcp.gitlab.com/token",
    "headers": {
      "Authorization": "Bearer TRUNCATED"
    },
    "format": {
      "type": "json",
      "subject_token_field_name": "token"
    }
  }
}

I then try to list artifacts in an Artifact Registry repository, and crane returns the error No matching credentials were found for "us-east1-docker.pkg.dev". However, doing the same with gcloud works just fine.

The only way I got this to work with crane was to use docker-credential-gcr or gcloud auth configure-docker to configure auth.

So it seems that crane fails to identity the environment credentials, and the only fallback that works is the Docker config (if any).

To Reproduce

This is based on an experimental GitLab feature that is not yet released. I can give access to a maintainer from Google for debug purposes if needed.

Expected behavior

crane is able to identify and use environment credentials.

Additional context

Here are some logs. I'm using the latest (v0.19.0) version of crane.

crane 🔴

crane-nok.log

gcloud 🟢

gcloud-ok.log

crane + docker config 🟢

crane-ok.log

Local test 🔴 🟢

I get the exact same result (crane does not work, gcloud does) when running this locally.

local.log

@joaodrp joaodrp added the bug Something isn't working label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant