Skip to content

Add support for checking permissions beyond merge (e.g. triage) #984

Description

@sergio-correia

Description

can_merge_pr(username) checks if a user has admin or write permission on a GitHub repository. packit-service uses this to decide who can trigger commands like /packit test on PRs, but "can merge" is not the right question for "can interact with the bot".

GitHub's "triage" role grants permissions that are conceptually sufficient for triggering CI (close/reopen issues and PRs, request reviews, manage labels) without granting write access to repository contents.

Benefit

This would allow project maintainers to give collaborators the triage role instead of write, letting them trigger /packit test and similar commands without granting unnecessarily broad repository access.

Importance

Today, the only way to let someone trigger packit commands is to give them write access, which violates least-privilege. There is no way to distinguish "can trigger CI" from "can push code" in the permission model.

Proposal:

Add a method that checks against a broader set of permissions. Either a targeted one:

def can_trigger_ci(self, username: str) -> bool:
    # accepts {"admin", "write", "maintain", "triage"}

or a more general one using GitHub's permission hierarchy (read < triage < write < maintain < admin):

def has_at_least_permission(self, username: str, level: str) -> bool:

This would let consumers like packit-service use the appropriate check for the action being authorized.

Workaround

  • There is an existing workaround that can be used until this feature is implemented.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)

Metadata

Metadata

Assignees

Labels

kind/featureA request, idea, or new functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions