Search code examples
securityazure-devopspermissionsrepositorydevops

Repo-level security permissions using az devops CLI?


Is it possible through az devops CLI (for ex: az devops security permissions commands) to set repo security settings at the repo level so that a repo may only be visible/accessible to specific users (and admin) in the project?

I am essentially looking for commands which will grant a specific user access to a specific repo @ repo-level


Solution

  • I am essentially looking for commands which will grant a specific user access to a specific repo @ repo-level

    You can use az devops security permission update Azure Cli and use 2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87 as the id parameter:

    az devops security permission update --id 2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87
                                         --subject
                                         --token
                                         [--allow-bit]
                                         [--deny-bit]
                                         [--detect {false, true}]
                                         [--merge {false, true}]
                                         [--org]
    

    Is it possible through az devops CLI to set repo security settings at the repo level so that a repo may only be visible/accessible to specific users in the project?

    Yes. Here is an example. Please replace the braces and their contents with your own information:

    az devops security permission update --id 2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87 --subject {email address or group descriptor} --token repoV2/{project id}/{repository id}/ --allow-bit 2 --merge true
    

    Please notice the --allow-bit 2. The number 2 refer to the Read permission of a repository.

    So if you want to let a user/group can access to a repository, you need to use --allow-bit 2. If you want to let a user/group cannot access to a repository, you need to use --deny-bit 2.