--- title: "ADR 0029: Bitbucket sender authorization reads OWNERS from the default branch" --- * Status: accepted * Code: [`pkg/provider/bitbucketcloud/acl.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketcloud/acl.go), [`pkg/provider/bitbucketdatacenter/acl.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketdatacenter/acl.go), [`pkg/provider/bitbucketcloud/bitbucket.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/bitbucketcloud/bitbucket.go) ## Context A pull request can change any file, including `OWNERS` and `OWNERS_ALIASES`. If the files on the PR head decided who may trigger CI, a sender could authorize themselves. Bitbucket Cloud also supports repository access tokens, which cannot read the workspace member list. ## Decision * `IsAllowedOwnersFile` reads `OWNERS` and `OWNERS_ALIASES` at `event.DefaultBranch`, never at the PR head. The Bitbucket Cloud test mounts a conflicting `OWNERS` at the PR revision to assert it is not consulted. * A missing `OWNERS` file means "not allowed through OWNERS", not an error. A missing `OWNERS_ALIASES` is tolerated; any other error is returned. * In `checkMember` (Cloud) and `checkMemberShip` (Data Center), a failure while reading the OWNERS file is not propagated: the final answer is simply "not allowed". An API failure there would normally have surfaced already in the earlier workspace or project/repository permission calls. * Order on Bitbucket Cloud: workspace membership, then OWNERS, then an `/ok-to-test` comment from an approved member. On Data Center: project membership, repository collaborator, then OWNERS; commenters of `/ok-to-test` are checked with the same membership function. * On Bitbucket Cloud, a token starting with `accessTokenPrefix` selects bearer authentication, and a 401 or 403 from the workspace members call is treated as "not a member" instead of an error. The sender is then still validated through OWNERS and approved comments. ## Consequences * Adding someone to `OWNERS` takes effect only after the change reaches the default branch. * With a repository access token, workspace membership alone never authorizes a sender on Cloud; OWNERS or an approved comment is required. * Transient errors reading OWNERS are indistinguishable from a missing file for the final decision.