获取谁有权访问git存储库的列表

时间:2017-09-25 18:30:12

标签: azure-devops azure-devops-rest-api

使用VSTS API,我试图获取一个列表,列出谁拥有对VSTS中每个git存储库的访问权限。

我有Git的security namespaceId,我把这个namespaceId传递给了Security - >此处描述的访问控制列表API: https://www.visualstudio.com/en-us/docs/integrate/api/security/acls

GET https://xxxxxxxx.visualstudio.com/DefaultCollection/_apis/accesscontrollists/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/?api-version=1.0&recurse=true&includeExtendedInfo=false

深入了解回复,我看到它列出了每个回购的权限,以及ref和标记。

每个对象都包含" acesDictionary",它本身就是一个带有如下所示键的对象:

Microsoft.IdentityModel.Claims.ClaimsIdentity;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\emailaddress@example.com

如何破译ClaimIdentity?我的第一个想法是,ClaimsIdentity中的UUID是我的VSTS项目中用户的UUID,但事实并非如此。我知道电子邮件地址在那里,所以我想我可以使用它,但现在我很好奇ClaimsIdentity中的UUID代表什么。 VSTS API文档不提这个。

安全 - >访问控制列出我应该看的正确位置?我的主要目标是尝试获取一个列表,其中包含对VSTS git存储库的访问权限。

1 个答案:

答案 0 :(得分:0)

通过技术支持,我能够联系到一位微软代表,他与我分享了映射身份描述符的文档尚未提供,但很快就会发布。与此同时,有一个人行横道身份描述符的端点,如下所示:

获取{account} .vssps.visualstudio.com / _apis / identities?descriptors = {commaSeparatedDescriptorsList}& api-version = {apiVersion}

请注意,此次来电是通过SPS {account}.vssps.visualstudio.com进行的,而不是通过您的帐户实例{account}.visualstudio.com进行的。

使用我的例子,它看起来像这样(uuid混淆):

https://xxxxx.vssps.visualstudio.com/_apis/identities?descriptors=Microsoft.TeamFoundation.ServiceIdentity;ffead5b1-5121-4e0e-a439-bbecb4999eba:Build:c4bfb762-a246-46c9-ba9a-7e6c53386b11&api-version=4.0

此外,如果描述符的类型为Microsoft.IdentityModel.Claims.ClaimsIdentity,那么您可能已经在描述符中转义了反斜杠,您需要取消它。例如,如果您有:

“Microsoft.IdentityModel.Claims.ClaimsIdentity; XXXXXXXXXXXX-XXXXXXXX-XXXXXXXXXXXX \\ someone@example.com”

您需要取消转义此描述符,使其如下所示:

“Microsoft.IdentityModel.Claims.ClaimsIdentity; XXXXXXXXXXXX-XXXXXXXX-XXXXXXXXXXXX \ someone@example.com”