mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 15:29:22 +01:00
* fix(teardown): stop offering a repo deletion no token can perform
Deleting a project with ?deprovision=delete-repo returned
502 {"error":"GitHub delete failed (403)",
"detail":"Must have admin rights to Repository."}
found by running the whole create-and-reverse path against production.
The cause is not a permissions mistake: GitHub requires the delete_repo
scope, and neither credential this product holds asks for it — the org
token has gist/read:org/repo/workflow, the user OAuth grant has
read:user/user:email/repo/workflow. So no FleetCrown token can ever
delete a repository, and the button offering it could only ever fail.
That is the right security posture, so keep it and make the product
honest about it instead:
- the teardown UI drops the delete option and links to the repository's
own Settings page on GitHub, where the owner has rights we never borrow
- a delete attempted through the API reads GitHub's x-oauth-scopes header
(sent on every response, errors included), and when delete_repo is
genuinely absent says so, lists what the token does have, and gives the
URL — rather than echoing a 403 nobody can act on. A token that DOES
hold the scope and still gets 403 keeps the real message.
- retire-site.sh --repo delete refuses up front, before the service,
vhost and files are gone, instead of failing at the last step
Verified against production: repo creation 200, archive 200, publish to
OrangeCat then take it down (public page 200 -> 404), project delete 200.
scripts/test/repo-delete-capability.ts pins both halves of the contract
and fails if either comes back.
* fix(retire): warn while it is a plan, refuse only when told to go
CI runs a GitHub token without delete_repo, so the new preflight aborted
the DRY RUN and took the whole retire-site suite with it. A plan that
cannot run is still worth reading: it now says the scope is missing, and
only --go refuses outright, before anything is torn down.
The test stubs both answers from gh rather than inheriting whichever
token the machine happens to hold — CI has no delete_repo, a laptop may.