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

Add auth-required to config.json for Cargo http registry #26729

Merged
merged 12 commits into from
Aug 28, 2023

Conversation

merlleu
Copy link
Contributor

@merlleu merlleu commented Aug 25, 2023

Cargo registry-auth feature requires config.json to have a property auth-required set to true in order to send token to all registry requests.
This is ok for git index because you can manually edit the config.json file to add the auth-required, but when using sparse
(setting index url to "sparse+https://git.example.com/api/packages/{owner}/cargo/"), the config.json is dynamically rendered, and does not reflect changes to the config.json file in the repo.

I see two approaches:

  • Serve the real config.json file when fetching the config.json on the cargo service.
  • Automatically detect if the registry requires authorization. (This is what I implemented in this PR).

What the PR does:

  • When a cargo index repository is created, on the config.json, set auth-required to wether or not the repository is private.
  • When the cargo/config.json endpoint is called, set auth-required to wether or not the request was authorized using an API token.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 25, 2023
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 25, 2023
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 26, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 26, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 27, 2023
@lunny lunny requested a review from KN4CK3R August 27, 2023 02:31
routers/api/packages/cargo/cargo.go Outdated Show resolved Hide resolved
services/packages/cargo/index.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Aug 27, 2023
@merlleu merlleu requested a review from KN4CK3R August 27, 2023 13:15
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Aug 27, 2023
@lunny lunny removed the request for review from KN4CK3R August 28, 2023 01:05
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Aug 28, 2023
@lunny lunny requested a review from KN4CK3R August 28, 2023 01:06
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Aug 28, 2023
@KN4CK3R KN4CK3R enabled auto-merge (squash) August 28, 2023 06:33
@KN4CK3R KN4CK3R merged commit a587d25 into go-gitea:main Aug 28, 2023
23 checks passed
@GiteaBot GiteaBot added this to the 1.21.0 milestone Aug 28, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 29, 2023
* giteaofficial/main:
  Add fix incorrect can_create_org_repo for org owner team (go-gitea#26683)
  [skip ci] Updated translations via Crowdin
  Improve modal dialog UI (go-gitea#26764)
  Improve the "bug report" template and "support options" document (go-gitea#26753)
  Unify `border-radius` behavior (go-gitea#26770)
  Reduce some allocations in type conversion (go-gitea#26772)
  Refactor some CSS styles and simplify code (go-gitea#26771)
  Add auth-required to config.json for Cargo http registry (go-gitea#26729)
  refactor(API): refactor secret creation and update functionality (go-gitea#26751)
@denyskon denyskon added the type/enhancement An improvement of existing functionality label Nov 13, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Nov 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. topic/packages type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants