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.
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.
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.
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.
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.
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.
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.
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.
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With