Lesson 3 of 6 Repository Management

Configuring Repository Permissions

This lesson explains permissions in Azure Repos and repository roles in GitHub.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe Azure Repos permission levels.
  • Explain how Deny and Allow resolve.
  • Describe the five GitHub repository roles.
  • Apply least privilege to repositories.

Permissions in Azure Repos

Azure Repos permissions are set under Project settings > Repositories. They exist at three levels: all repositories in a project, a single repository, and a single branch. Lower levels inherit from higher ones, so a default can be set for all repositories, then tightened where required.

The following permissions are the ones that matter most.

PermissionWhat it allows
ReadClone and view the code
ContributePush to branches and create branches
Contribute to pull requestsCreate and comment on pull requests
Create branchCreate new branches
Create tagCreate tags
Force push (rewrite history, delete branches and tags)Rewrite or delete history
Bypass policies when completing pull requestsComplete without meeting branch policies
Bypass policies when pushingPush directly despite branch policies
Manage permissionsChange who has access

Each permission can be Allow, Deny, or Not set. An explicit Deny overrides an inherited or group Allow, and Not set means that access is denied unless granted elsewhere. Because users usually belong to several groups, the effective permission is what matters, and the permissions page shows a Trace link that explains how a value was reached. Permissions should be given to groups, such as Contributors or a custom group, and not to individuals.

Branch-level permissions allow patterns such as limiting who can create branches at the root. Some teams require branches in folders, such as users/ or feature/, by denying branch creation at the root and allowing it within those folders.

Scenario questions

Effective permissions in Azure Repos

Exam skills 2.2.3

Work out what a user can do from Allow, Deny and inheritance.

Log in to try this activity Interactive activities are free with an account.

Permissions in GitHub

In GitHub, access comes from repository roles. The five standard roles form a ladder, each including what comes before it.

RoleIntended forKey abilities
ReadViewers and contributors who raise issuesClone, open issues and comment
TriagePeople who manage issues without writing codeLabel, assign and close issues and pull requests
WriteActive contributorsPush to non-protected branches, and merge pull requests
MaintainProject managers of a repositoryManage some settings, without destructive actions
AdminRepository ownersFull control, including settings and deletion

Roles are best assigned to teams. An organization's base permission sets what all members receive on all repositories, and it should be low, usually Read or No permission. GitHub Enterprise Cloud supports custom repository roles, which add fine-grained permissions to a base role, for example allowing someone to manage webhooks without broader administration. The module on authentication covers GitHub roles at organization level.

Sort into groups

Which GitHub repository role?

Exam skills 2.2.3

Find the lowest standard repository role that covers each person's needs.

Log in to try this activity Interactive activities are free with an account.

Applying least privilege

Several principles apply on both platforms. Grant access through groups so that a leaver's access ends with their group membership. Give pipelines their own limited identity and not a person's credentials. Keep the number of administrators small. Review access regularly. Note that in Azure Pipelines, the Project Build Service identity usually needs Contribute permission on a repository only if a pipeline pushes back to it, for example to create tags.

The following diagram resolves a contractor's effective Contribute permission from an inherited Allow and an explicit Deny.

Resolving Contribute for the contractor. The Contributors group allows Contribute on every repository; an explicit Deny for the contractor on the sensitive repository overrides that inherited Allow, so the contractor can push everywhere except there, and other contributors are unaffected.
Only the Contribute permission is shown.
Select all that apply

Least privilege for repositories

Exam skills 2.2.3

Pick the practices that keep repository access minimal.

Log in to try this activity Interactive activities are free with an account.
Worked example

Restricting one person

In Azure Repos, a contractor belongs to the Contributors group, which allows Contribute on all repositories. The contractor must not push to one sensitive repository, but must keep access to the others. What should you do with the least effort?

You should add a Deny on Contribute for the contractor, or for a group holding such contractors, on that one repository. Deny overrides the Allow inherited from Contributors. Removing the contractor from Contributors would remove access to the other repositories. Clearing the group's Allow on that repository would affect all contributors.

Check yourself

A permission is Not set at every level for a user. Can the user perform the action?

Show answer

No. Not set is an implicit deny, unless an Allow exists from another source.

Exam Tips

Remember for the exam

  • Azure Repos permissions exist at project, repository and branch levels.
  • Deny overrides Allow; Not set means no access unless granted elsewhere.
  • GitHub roles: Read, Triage, Write, Maintain, Admin.
  • Assign roles to teams, and keep base permissions low.
  • Restrict force push and bypass permissions to a very small group.