problem: /api/v1/repos/{owner}/{repo}/branch_protections responses with 403 for public-only key #12397

Open
opened 2026-05-03 13:55:39 +02:00 by Maks1mS · 1 comment
Maks1mS commented 2026-05-03 13:55:39 +02:00 (Migrated from codeberg.org)

Does your problem still exist on the latest Forgejo version?

Yes, the problem still exists (tested on a next instance)

About your usage of Forgejo

n/a

Problem description

Steps to reproduce:

  1. Create public repository.
  2. Create access token with public only token with write:repository.
  3. Go to /api/swagger#/repository/repoCreateBranchProtection and send request (after logging in with a token). The body can be empty in JSON format, it doesn't matter.

Expected:

  • the error is not 403

Actual:

  • the error is 403 (user should be an owner or a collaborator with admin write of a repository)

It looks like a regression, because I used v11 earlier and there were no problems.

Potential workarounds

Use access token with All (public, private, and limited) option.

Forgejo Version

16.0.0-dev-218-b6658076a9+gitea-1.22.0

Other details about your environment (software names and versions)

n/a

Solutions

Accepted solutions to address this problem will go here

### Does your problem still exist on the latest Forgejo version? Yes, the problem still exists (tested on a next instance) ### About your usage of Forgejo n/a ### Problem description Steps to reproduce: 1. Create public repository. 2. Create access token with public only token with `write:repository`. 3. Go to [`/api/swagger#/repository/repoCreateBranchProtection`](https://v16.next.forgejo.org/api/swagger#/repository/repoCreateBranchProtection) and send request (after logging in with a token). The body can be empty in JSON format, it doesn't matter. Expected: - the error is not 403 Actual: - the error is 403 (`user should be an owner or a collaborator with admin write of a repository`) It looks like a regression, because I used v11 earlier and there were no problems. ### Potential workarounds Use access token with `All (public, private, and limited)` option. ### Forgejo Version 16.0.0-dev-218-b6658076a9+gitea-1.22.0 ### Other details about your environment (software names and versions) n/a ### Solutions *Accepted solutions to address this problem will go here*
mfenniak commented 2026-05-04 05:46:27 +02:00 (Migrated from codeberg.org)

It is noted in Forgejo 15's release notes that there is a breaking change, "remove admin-level permissions from repo-specific & public-only access tokens" (#11468). Changing branch protection rules on a repository requires repository admin access, which is why it has been affected by this breaking change -- and that is one of the APIs described in the details noted in #11468.

Please review the explanation in #11468. The logic behind this change is open for debate and discussion, and within this larger context of related changes, I'd be open to discussing how these changes could be made in a logical and secure way.

It is noted in Forgejo 15's release notes that there is a breaking change, "remove admin-level permissions from repo-specific & public-only access tokens" (#11468). Changing branch protection rules on a repository requires repository admin access, which is why it has been affected by this breaking change -- and that is one of the APIs described in the details noted in #11468. Please review the explanation in #11468. The logic behind this change is open for debate and discussion, and within this larger context of related changes, I'd be open to discussing how these changes could be made in a logical and secure way.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/forgejo#12397
No description provided.