Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically query permissions on a Git repository hosted on TFS

I have been trying to figure out method of fetching permissions on a particular Git Repository programmatically.

The TFS API reference given online doesn't detail any of the security API's. However, this is definitely done in TFS when you or view modify security from the web portal.

Tracking the web calls, I can see that calls being made to the following API

http://tfsserver/tfs/DefaultCollection/[TeamProject]/_api/_security/DisplayPermissions?
__v=5&tfid=[PROJ_GUID]&permissionSetId=[PERMMISSIONSET_GUID]
&permissionSetToken=repositories/[REPOSITORY_GUID].

I have inferred all the GUIDS passed to the above URL but couldn't understand where to get the GUID for fill the PermissionSetId parameter.

Looking at the web page, I can see that the value picked up from gitRepositoryPermissionSet, but I can't find it out how to get this value.

Wondering if anyone can help me out with understanding this parameter.

like image 530
Hamid Shahid Avatar asked Jan 30 '15 18:01

Hamid Shahid


People also ask

How do I check permissions on a Git repository?

You set Git repository permissions from Project Settings>Repositories. Open the web portal and choose the project where you want to add users or groups. To choose another project, see Switch project, repository, team. Open Project settings>Repositories.

Can you use Git with TFS?

Git in Visual Studio, Azure DevOps Services, and TFS is standard Git. You can use Visual Studio with third-party Git services, and you can also use third-party Git clients with TFS. To learn more, see Git and Azure Repos.

How do I give permission to GitHub repository?

Under your repository name, click Settings. In the "Access" section of the sidebar, click Collaborators & teams. Click Invite a collaborator. In the search field, start typing the name of person you want to invite, then click a name in the list of matches.

How do I give someone access to my Git?

On GitHub, click the “Settings” button on the right, select “Collaborators”, click “Add people”, and then enter your partner's username. To accept access to the Owner's repo, the Collaborator needs to go to https://github.com/notifications or check for email notification.

What permissions can I set on a git repository?

These permissions appear only for a team project set up to use Git as the source control system. You can set all permissions for a project or repository. You can set Administer, Contribute, and Rewrite and destroy history (force push) permissions for a branch.

How do I set Git permissions in TWA?

You can set permissions on a Git project, repository, or branch from the context menu or from the administration page in TWA, or by using the TFSSecurity command line tool. These permissions appear only for a team project set up to use Git as the source control system. You can set all permissions for a project or repository.

What are permissions in TFS?

Permissions determine what tasks users can and can't do. For users to have access to Team Foundation Server (TFS) resources and team projects, you need to add them to a team project or TFS group. For an overview of how TFS manages membership, permissions, and access, see Manage users and groups in TFS.

How do I add users and groups to a git repository?

Open the web portal and choose the project where you want to add users or groups. To choose another project, see Switch project, repository, team. Open Project settings>Repositories. To set the permissions for all Git repositories, choose Security. For example, here we choose (1) Project settings, (2) Repositories, and then (3) Security.


Video Answer


1 Answers

Back in 2015 there was no good API for this yet, but since things have changed. There is now a complete REST api for permissions, tfssecurity can be used and Azure-CLI has been extended with the ability to query and set permissions.

I've written a blog post recently that explores Git Repository permissions:

  • https://jessehouwing.net/azure-devops-git-setting-default-repository-permissions/
  • https://docs.microsoft.com/en-us/rest/api/azure/devops/security/?view=azure-devops-rest-5.1
like image 154
jessehouwing Avatar answered Sep 21 '22 05:09

jessehouwing