Add Codeberg support to the Web UI#478
Open
abcdvvvv wants to merge 1 commit intoJuliaRegistries:masterfrom
Open
Add Codeberg support to the Web UI#478abcdvvvv wants to merge 1 commit intoJuliaRegistries:masterfrom
abcdvvvv wants to merge 1 commit intoJuliaRegistries:masterfrom
Conversation
Author
|
The current CI failure is expected for now because this PR depends on JuliaWeb/GitForge.jl#55. This branch now imports Locally, I tested this branch with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Web UI support for registering packages hosted on Codeberg. It depends on the Forgejo support added in JuliaWeb/GitForge.jl#55.
With this change, Registrator can authenticate with Codeberg, inspect a package repository hosted there, and submit the registration request against the configured registry through the usual Web UI flow.
Scope
This PR is intentionally limited to the Web UI path.
It does not add comment-triggered registration on Codeberg. The final registry PR workflow is unchanged as well: for
General, Registrator still opens the registration PR on GitHub.What Changed
codebergas a built-in Web UI providerForgejoAPIinto the provider, auth, and callback flowroutes/auth.jlto include Codeberggitutils.jlfor authorization checks, project file loading, commit lookup, clone URL construction, web URL rendering, and tag mismatch checksWhy The OAuth Changes Are Needed
Live testing against Codeberg also exposed two places where the existing Web UI assumptions did not hold.
First, the callback token exchange in
src/webui/routes/callback.jlcould not complete successfully with the previous implementation. Registrator was sending the OAuth token exchange parameters in the POST query string. In live testing, Codeberg responded with400 Bad Request,unsupported_grant_type, and the messageOnly refresh_token or authorization_code grant type is supported, even though the request still includedgrant_type=authorization_code. In practice, moving those parameters into anapplication/x-www-form-urlencodedPOST body fixed the callback flow. This is therefore a functional fix, not a stylistic cleanup.Second, even after OAuth login succeeded, the returned Codeberg OAuth token still could not read repository metadata through
GET /repos/{owner}/{repo}in the way the existing Web UI authorization path expected. In practice, the user could authenticate successfully, but the subsequent repo refresh step still failed with aread:repositoryerror.That behavior is consistent with the current Forgejo documentation, which explicitly notes that OAuth2 scopes are not yet implemented and distinguishes OAuth2 tokens from scoped personal access tokens:
So the problem here was not that Registrator requested the wrong scope. The issue was that the previous Web UI flow assumed stronger repository-read semantics from a Forgejo OAuth token than the platform currently guarantees.
The Forgejo authorization path is therefore adjusted so the OAuth token is still used to identify the logged-in user, while repository lookup and authorization fallback can continue using the configured server-side Codeberg client when that user-token repo refresh fails. If the user-token refresh succeeds, Registrator still trusts the per-user
permissions.pushfast path. If it fails, Registrator falls back to collaborator, owner, and membership checks instead of rejecting the registration immediately.This does not change the high-level behavior for the existing built-in providers. Registrator still performs the same callback and token exchange flow against each provider's configured
token_url; the Codeberg-specific change is that the token exchange parameters are now sent in the request body, and the Forgejo authorization path is able to fall back cleanly when user-token repo refresh is unavailable.Validation
julia --project=. test/runtests.jlpasses (120 / 120)gitutilstests now cover the Codeberg / Forgejo pathread:repositoryRegServiceRelated
Generated with Codex assistance.