8

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.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Hamid Shahid
  • 4,486
  • 3
  • 32
  • 41

2 Answers2

1

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:

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
0

If you view the Git repository in web browser and do a view-source, you will get HTML source of it. There you will find something like this:

<script class="options" defer="defer" type="application/json">
{"tfsRepositoryPermissionSet":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
 **"gitRepositoryPermissionSet":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"**,
 "projectGuid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
 "projectUri":"vstfs:///Classification/TeamProject/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
 "projectVersionControlInfo":{
     "supportsGit":true,
     "project":{
         "id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "name":"xxxxxx",
         "url":"http://xxx:xxx/xxx/xxxxxxxxxxxxxxxx/_apis/projects/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "state":"wellFormed"
     }
 },
 "gitRepositories":[
     {"id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","name":"xx

This is what you are most probably looking for.

C14L
  • 12,153
  • 4
  • 39
  • 52
The Shooter
  • 733
  • 3
  • 9