-
Notifications
You must be signed in to change notification settings - Fork 673
trustpub/tokens/exchange: Implement GitLab CI support #12026
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
base: main
Are you sure you want to change the base?
Conversation
b2d6282
to
d2eea95
Compare
d2eea95
to
4449eed
Compare
4449eed
to
bfd48ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
insert_jti(conn, &signed_claims.jti, signed_claims.exp).await?; | ||
|
||
let project_path = &signed_claims.project_path; | ||
let Some((namespace, project)) = project_path.rsplit_once('/') else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know why this is rsplit_once
(the GitLab optional project thing), but it might be worth a comment explaining why this differs from GitHub, since rsplit_once
versus split_once
is pretty subtle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I thought I had left a comment on that, but apparently not. I'll add one. 👍
|
||
if repo_configs.is_empty() { | ||
let message = format!( | ||
"The Trusted Publishing config for repository `{project_path}` does not match the namespace ID ({}) in the JWT. Expected namespace IDs: {}. Please recreate the Trusted Publishing config to update the namespace ID.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really good explanation. 👍
This PR adjusts our
POST /api/v1/trusted_publishing/tokens
endpoint to also accept GitLab OIDC tokens.As discussed in #11988, we are using a trust-on-first-use principle for the namespace IDs for GitLab due to some API constraints. In other words: the token exchange endpoint will fill in the
namespace_id
column from the OIDC JWT claims if it was empty before and on each subsequent token exchange it will only accept it if the IDs are matching.Other than that, this is essentially the same implementation as for GitHub Actions.
Worth noting also is that, just like PyPI, we only support gitlab.com for now, but not any self-hosted GitLab instances.
Related