Skip to content

proposal: API for querying collaborator permissions #14936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 6 tasks
nome opened this issue Mar 9, 2021 · 3 comments
Closed
2 of 6 tasks

proposal: API for querying collaborator permissions #14936

nome opened this issue Mar 9, 2021 · 3 comments
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@nome
Copy link

nome commented Mar 9, 2021

Description

Context: I have defined a team with can_create_org_repo and write permission to all repos. Team members are considered maintainers/contacts for the repositories they have admin privileges on. Now I want other members of the same team to be able to query (via a custom client) the admin(s) of a given repo.

In the GitHub API, GET /repos/{owner}/{repo}/collaborators returns the permissions of each collaborator along with the user info, e.g. "permissions": { "pull": true, "push": true, "admin": false }. I think this would be the preferred way of implementing this feature.

Possible alternatives:

  • GET /repos/{owner}/{repo}/collaborators/{username}/permission - less efficient in this use case, because it would require multiple requests
  • Filter collaborators returned in GET /repos/{owner}/{repo}/collaborators by their permissions using an optional parameter - would deviate from the GitHub API
  • Add a separate endpoint, e.g. GET /repos/{owner}/{repo}/permissions for querying collaborator permissions - would deviate from the GitHub API

Screenshots

@Greg-NetDuma
Copy link

GET /repos/{owner}/{repo}/collaborators/{collaborator} currently returns an empty response, it could return the permissions for that user if the user is a collaborator.

@noerw noerw added modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Mar 11, 2021
@zeripath
Copy link
Contributor

lol this was one of my first prs that was rejected as it changed the api...

6543 pushed a commit that referenced this issue Apr 29, 2022
Targeting #14936, #15332

Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository.

### Checks the repository permissions of a collaborator. 

`GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission`

Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`.

```json
{
  "permission": "admin",
  "role_name": "admin",
  "user": {}
}
```

Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
@6543
Copy link
Member

6543 commented Apr 29, 2022

-> #18761

@6543 6543 closed this as completed Apr 29, 2022
@6543 6543 added this to the 1.17.0 milestone Apr 29, 2022
Gusted pushed a commit to Gusted/gitea that referenced this issue Apr 30, 2022
…18761)

Targeting go-gitea#14936, go-gitea#15332

Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository.

### Checks the repository permissions of a collaborator. 

`GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission`

Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`.

```json
{
  "permission": "admin",
  "role_name": "admin",
  "user": {}
}
```

Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 24, 2022
…18761)

Targeting go-gitea#14936, go-gitea#15332

Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository.

`GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission`

Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`.

```json
{
  "permission": "admin",
  "role_name": "admin",
  "user": {}
}
```

Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

5 participants