-
Notifications
You must be signed in to change notification settings - Fork 3
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
User error question: Failure to get valid OIDC token with id with GitLab #216
Comments
Hi @matthewfeickert , thanks for the bug report! The namespace issue is definitely a bug on PyPI's side, I'll create a fix for it. As for the general problem though, the issue is that PyPI does not currently support self-hosted GitLab instances. That is, we only validate OIDC tokens where the issuer in the claims is Looking at our docs, it looks like we didn't make this explicit, so that's definitely something we can fix. But for now, I'm afraid the only way to use Trusted Publishing with GitLab is when using the official (and just for clarification, this is all on PyPI's side: |
Linking pypi/warehouse#15836, which tracks the namespace bug on PyPI's side |
Thanks @facutuesca. As this isn't a |
I don't believe there is one, but feel free to create one! |
@matthewfeickert Just curious here, if you install this library and run (You can share the results here, the signature should be redacted by that command). |
@di Yes. For the following (non-minimal because I'm doing a lazy edit) YAML:stages:
- deploy
variables:
# see https://docs.gitlab.com/ee/ci/caching/#cache-python-dependencies
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
cache:
paths:
- .cache/pip
- venv/
image: python:3.11-bullseye
before_script:
# want to set up a virtualenv to cache
- apt-get update
- apt-get install -y --no-install-recommends git jq
- python -V
- git config --global credential.helper 'cache'
- python -m venv venv
- source venv/bin/activate
- python -m pip install -U pip pipx id
- python -m pipx ensurepath
- python -m pip freeze --local
publish-job:
stage: deploy
id_tokens:
THROWAWAY_ID_TOKEN:
aud: pypi
script:
- python -m id throwaway --decode I get $ python -m id throwaway --decode
{"kid":"Yi4Qlfo9GsiLCsaxm96WMTz1BxCGsKtiQ8wqEpQTIyM","typ":"JWT","alg":"RS256"}
{"namespace_id":"17511","namespace_path":"atlas-itk/sw/db","project_id":"62567","project_path":"atlas-itk/sw/db/itkdb","user_id":"6121","user_login":"feickert","user_email":"[email protected]","user_access_level":"developer","pipeline_id":"7274672","pipeline_source":"push","job_id":"38298873","ref":"debug/test-id-package","ref_type":"branch","ref_path":"refs/heads/debug/test-id-package","ref_protected":"false","runner_id":34772,"runner_environment":"self-hosted","sha":"6fa49a6a13d4772c712a208f0e15deebecae53c2","project_visibility":"public","ci_config_ref_uri":"gitlab.cern.ch/atlas-itk/sw/db/itkdb//.gitlab-ci.yml@refs/heads/debug/test-id-package","ci_config_sha":"6fa49a6a13d4772c712a208f0e15deebecae53c2","jti":"590c0fd4-95a7-485c-85a8-1d0647d6a10a","iss":"https://gitlab.cern.ch/","iat":1713888962,"nbf":1713888957,"exp":1713892562,"sub":"project_path:atlas-itk/sw/db/itkdb:ref_type:branch:ref:debug/test-id-package","aud":"pypi"} (Sorry about the first response I deleted. I forgot to set the |
OK, seems like this should work fine here then. Thanks! |
👋 Hi. This is a user error (as in I'm doing this wrong) question, so if there is a prefered different place to ask them please let me know and I'll move this.
Now that PyPI Trusted Publishers should be able to work with GitLab CI/CD @kratsg and myself are interested in using them for publication of tools being built on CERN's EE GitLab instance (https://gitlab.cern.ch/) (currently
v16.9.4-ee
and so should supportid_tokens
) as we've been using them with GitHub Actions and enjoying them.However, though @kratsg has setup the PyPI package https://pypi.org/project/itkdb/ to support trusted publishers coming from GitLab CI/CD attempting to get a debug version of a
.gitlab-ci.yml
workflow to just get a OIDC token fromid
and then exchange it for a PyPI API token fails asresults in an
invalid-payload
error.As this error is indicating that
python -m id PYPI
is failing to retrieve a valid OIDC token in the current setup on CERN's GitLab do you have debugging advice, related toid
?Namespace aside (possibly main problem)
The project lives as an internal project at https://gitlab.cern.ch/atlas-itk/sw/db/itkdb/ so @kratsg selected a namespace of
atlas-itk
as trying with the full namespace of
atlas-itk/sw/db
failed withcc @henryiii as also somewhat related to scientific-python/cookie#411
The text was updated successfully, but these errors were encountered: