Skip to content

feat(repo): add the gpg-key and repo collaborator commands - #507

Merged
q-horde merged 20 commits into
developfrom
epic/481-keys-and-access
Nov 16, 2026
Merged

q-horde merged 20 commits into
developfrom
epic/481-keys-and-access

Conversation

@q-horde

@q-horde q-horde commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Epic E3 Keys and access (planning issue QUB-969): add the gpg-key and repo collaborator commands, each proven against live Copia, and record in docs/parity.md why gh ssh-key and gh repo deploy-key have no Copia counterpart.

New commands:

  • gpg-key list (alias ls), gpg-key add [<key-file>], gpg-key delete <key-id> --yes, as in gh. add sends an armored public key only: content with any other -----BEGIN header (a private or secret key, a signature, an SSH key) is refused before any request, and a server message that quotes the key is withheld. --signature is left out: Copia does not register GET /user/gpg_key_token, so only a key with a verified account email can be added.
  • repo collaborator list (alias ls), repo collaborator add <login> [-p/--permission read|write|admin] (default write), repo collaborator remove <login> --yes; gh has no such commands.

Other changes:

  • pkg/cmdutil: CheckArmor (public key allowlist) and ReadAPIMessage (error body read bounded to 64 KiB, message cut to 512 bytes).
  • docs/parity.md lists gh ssh-key and gh repo deploy-key as None on Copia: app.copia.io answers POST /user/keys with 422 SSH is disabled.
  • Integration tests: gpg-key list and a delete of a random key ID against live Copia (no test adds a GPG key to the account); the collaborator test adds the test account itself to the run repository, lists it and removes it. All under the no-account-data guard.

Slice PRs (merged into the epic, in merge order)

Not in this epic: ssh-key and repo deploy-key (Copia has SSH disabled); PR #487 was closed unmerged, #481, #47, #484 and #485 were closed as not planned.

Checklist

  • Every slice reviewed and merged into the epic
  • CHANGELOG, docs/parity.md, CLAUDE.md and the docs sidebar updated in the slices
  • go test ./... and golangci-lint run ./... on the epic head (see the review on the Paperclip issue)

The slice issues below were closed by hand when their slice merged into the epic; the lines keep the record.

Closes #482
Closes #483
Closes #486
Closes #50

Gitea returns no user ID of a GPG key, so each test key is marked by a
private scratch repository it-run-<time>-gk<key ID>. A GPG key is deleted
only when such a marker names its ID: on the test's cleanup, or for a
marker older than two hours at the start of a later run, before the stale
repository sweep deletes the marker.
Copia does not register GET /user/gpg_key_token, so gpg-key add drops
--signature (Lead decision on QUB-1230) and no integration test adds a
GPG key. Without one, the key fixture, its marker repositories and its
sweep have nothing to guard.

This reverts commit 64ada01.
Copia does not register GET /user/gpg_key_token (it answers Go's plain
404 page not found), so a token signature cannot be made. gpg-key add
now sends the armored key only, like gh, and Gitea's 404 for a key
without a verified email shows a hint to verify that email instead of
Gitea's offer to sign the token.
The test adds no key: Copia adds only a key with a verified email of the
account, which the tests never read.
ReadAPIMessage reads at most 64 KiB of an error body and cuts the
message to 512 bytes on a rune boundary, so a server cannot make
copia-cli read or print an error of any size. FetchPages uses it for
HTTPError.Message (security review QUB-1261, finding 3).
gpg-key add refused only PRIVATE KEY BLOCK, so an OpenSSH, PKCS#8, RSA
or legacy PGP secret key passed. cmdutil.CheckArmor is an allowlist:
every armor header must be the public key header, a header naming
PRIVATE or SECRET is refused as a private key. A server message that
holds 16 bytes in a row of the key material, compared without white
space, is left out of the error (security review QUB-1261, findings 1
and 2).
chore(epic): bring Go 1.27.4 from develop into epic/481-keys-and-access
Copia answers GET /repos/{owner}/{repo}/collaborators/{login}/permission
with a plain-text 404, so the list shows LOGIN and NAME only and --json
takes login and full_name. The integration test checks that the account
is listed after add -p read, without the permission-route probe.

Refs #486
…-list-add

feat(repo): add repo collaborator list and add
Check GET /repos/{owner}/{repo}/collaborators/{login} first, since Gitea
answers 204 to a delete of a non-collaborator, then DELETE it. --yes is
required and checked before anything else.

Closes #50
…remove

feat(repo): add repo collaborator remove
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.44419% with 20 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pkg/cmd/repo/collaborator/add/add.go 91.80% 5 Missing ⚠️
pkg/cmd/gpgkey/add/add.go 94.66% 4 Missing ⚠️
pkg/cmd/gpgkey/list/list.go 96.42% 3 Missing ⚠️
pkg/cmd/repo/collaborator/list/list.go 95.00% 3 Missing ⚠️
pkg/cmd/gpgkey/delete/delete.go 96.00% 2 Missing ⚠️
pkg/cmd/repo/collaborator/remove/remove.go 96.66% 2 Missing ⚠️
pkg/cmdutil/apimessage.go 92.30% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@q-horde
q-horde merged commit 0de82be into develop Nov 16, 2026
8 checks passed
@q-horde
q-horde deleted the epic/481-keys-and-access branch November 16, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant