|
| 1 | +In the previous unit, you explored how repository and team permissions work in GitHub and how users are granted access at those levels. In this unit, you'll learn how to manage permissions and access at a broader scale across organizations and enterprises: |
| 2 | + |
| 3 | +- Organization permissions |
| 4 | +- Enterprise permissions |
| 5 | +- Internal vs. external collaborators |
| 6 | +- Least privilege strategies |
| 7 | +- Security and governance best practices |
| 8 | + |
| 9 | +## Organization permission levels |
| 10 | +GitHub organizations provide a centralized way for teams to collaborate on projects while maintaining controlled access to repositories and sensitive data. Organization permissions determine what members and teams can do within the organization, ensuring that each user has the appropriate level of access. |
| 11 | + |
| 12 | +There are multiple levels of permissions at the organizational level: |
| 13 | + |
| 14 | +| **Permission level** | **Description** | |
| 15 | +|:----------------------|:--------------------------------------------------------------------------------------------------------------------------------| |
| 16 | +| Owner | Organization owners can do everything that organization members can do, and they can add or remove other users to and from the organization. This role should be limited to no less than two people in your organization. | |
| 17 | +| Member | Organization members can create and manage organization repositories and teams. | |
| 18 | +| Moderator | Organization moderators can block and unblock nonmember contributors, set interaction limits, and hide comments in public repositories that the organization owns. | |
| 19 | +| Billing manager | Organization billing managers can view and edit billing information. | |
| 20 | +| Security managers | Organization security managers can manage security alerts and settings across your organization. They can also read permissions for all repositories in the organization. | |
| 21 | +| Outside collaborator | Outside collaborators, such as a consultant or temporary employee, can access one or more organization repositories. They aren't explicit members of the organization. | |
| 22 | + |
| 23 | +In addition to these levels, you can also set default permissions for all members of your organization: |
| 24 | + |
| 25 | +:::image type="content" source="../media/org-base-permissions.png" alt-text="Screenshot of the member privileges screen with the base permissions dropdown displayed."::: |
| 26 | + |
| 27 | +For improved management and security, you might also consider giving default read permissions to all members of your organization and adjusting their access to repositories on a case-by-case basis. If you have a relatively small organization with a low number of users, a low number of repositories, or a combination of the two, this level of restriction might be unnecessary. If you trust everyone with pushing changes to any repository, you might prefer to give all members write permissions by default. |
| 28 | + |
| 29 | +## Enterprise permission levels |
| 30 | + |
| 31 | +Recall from earlier that enterprise accounts are collections of organizations. By extension, each individual user account that is a member of an organization is also a member of the enterprise. You can control various settings related to authentication from this higher level. |
| 32 | + |
| 33 | +There are three levels of permission at the enterprise level: |
| 34 | + |
| 35 | +| **Permission level** | **Description** | |
| 36 | +|:----------------------|:-----------------------------------------------------------------------------------------------------------------------------------| |
| 37 | +| Owner | Enterprise owners have complete control over the enterprise and can take every action, including: <br> - Managing administrators. <br> - Adding and removing organizations to and from the enterprise. <br> - Managing enterprise settings. <br> - Enforcing policies across organizations. <br> - Managing billing settings. | |
| 38 | +| Member | Enterprise members have the same set of abilities as organization members. | |
| 39 | +| Billing manager | Enterprise billing managers can only view and edit your enterprise's billing information and add or remove other billing managers. | |
| 40 | +| Guest collaborator | Can be granted access to repositories or organizations, but has limited access by default (Enterprise Managed Users only)| |
| 41 | + |
| 42 | +In addition to these three levels, you can also set a policy of default repository permissions across all your organizations: |
| 43 | + |
| 44 | +:::image type="content" source="../media/enterprise-base-permissions.png" alt-text="Screenshot of the policies screen with the default permissions dropdown displayed."::: |
| 45 | + |
| 46 | +For improved management and security, you can give default read permissions to all members of your enterprise and adjust their access to repositories on a case-by-case basis. In a smaller enterprise, such as one with a single, relatively small organization, you might prefer to trust all members with write permissions by default. |
| 47 | + |
| 48 | +To further streamline enterprise-scale access control: |
| 49 | + |
| 50 | +- **Nested Teams:** Enterprise accounts can use nested team structures to reflect departmental hierarchies. A parent team’s permissions cascade down to child teams, simplifying complex access management. |
| 51 | +- **Automation & Auditing:** You can use GitHub’s API or GitHub Actions to automate team creation and permission assignments, and audit access via organization or enterprise audit logs. |
| 52 | + |
| 53 | +## 4.3.4 Difference Between Organization Members and Outside Collaborators |
| 54 | + |
| 55 | +Understanding the distinction between an organization member and an outside collaborator is crucial for managing access and permissions effectively within GitHub. Here are the key differences: |
| 56 | + |
| 57 | +- **Organization Member:** |
| 58 | + - Included in the organization’s internal directory. |
| 59 | + - Can be assigned to one or more teams with varying levels of repository access. |
| 60 | + - May inherit organization-wide settings, such as SSO requirements or policies. |
| 61 | + |
| 62 | +- **Outside Collaborator:** |
| 63 | + - Not an official member of the organization. |
| 64 | + - Has explicit access to specific repositories only. |
| 65 | + - Does not appear in the organization’s internal member list. |
| 66 | + - Lacks broader visibility into private repositories and organization settings. |
| 67 | + |
| 68 | +## 4.3.5 Downsides of a User’s Membership in an Instance or Organization |
| 69 | + |
| 70 | +When a user becomes a member of a GitHub organization, several implications come into play that affect their access, visibility, and responsibilities within the organization. These consequences are important to understand for effective management and collaboration. |
| 71 | + |
| 72 | +- **Access to Private Repositories:** Organization members can view, clone, and contribute to private repos if granted the necessary permissions. |
| 73 | +- **Visibility:** Members appear in the organization’s people directory, which may affect discoverability. |
| 74 | +- **Policy Enforcement:** Security and compliance rules (e.g., SAML SSO, 2FA) apply to all organization members. |
| 75 | +- **Billing Implications:** Each member may count toward your organization’s license or billing plan. |
| 76 | +- **Team Collaboration:** Members can be grouped into teams, streamlining repository permissions and communication. |
| 77 | + |
| 78 | +## 4.3.6 Assigning Least Privilege to a User for Repository, Organization or Team |
| 79 | + |
| 80 | +Applying the Principle of Least Privilege ensures that users have only the permissions necessary to fulfill their roles: |
| 81 | + |
| 82 | +- **Repository Access:** |
| 83 | + - Assign the Read permission to most contributors. |
| 84 | + - Grant Write or Admin only if they need to commit code or manage settings. |
| 85 | + |
| 86 | +- **Organization Access:** |
| 87 | + - Start with Member and only elevate to Owner for those who need administrative control. |
| 88 | + - Use Billing Manager for financial responsibilities without granting code access. |
| 89 | + |
| 90 | +- **Team Access:** |
| 91 | + - Team Maintainer can manage team membership and settings. |
| 92 | + - Team Member is suitable for contributors who only need to participate in repository and team discussions. |
| 93 | + |
| 94 | +## 4.3.7 Benefits and Drawbacks of Creating a New Organization |
| 95 | + |
| 96 | +Creating a new organization within GitHub can help you manage projects, teams, and resources more effectively. Here are some benefits and drawbacks to consider: |
| 97 | +### Benefits and drawbacks of creating a new organization |
| 98 | + |
| 99 | +| Benefits | Drawbacks | |
| 100 | +|--------------------------------------------------------------------------|---------------------------------------------------------------------------| |
| 101 | +| **Clear Separation:** Keep projects, teams, and billing separate from other organizations. | **Administrative Overhead:** Managing multiple organizations can be more complex. | |
| 102 | +| **Custom Policies:** Apply specific security or compliance policies for different projects. | **Billing Complexity:** Each organization may need separate billing. | |
| 103 | +| **Scalability:** Avoid making a single organization too complex. | **Fragmented Collaboration:** Users might need to switch between organizations. | |
| 104 | + |
| 105 | +Consider these points to decide if creating a new organization is the right choice for your needs. |
| 106 | + |
| 107 | +## Repository security and management |
| 108 | + |
| 109 | +You can oversee the security and management of your repositories in several ways. |
| 110 | + |
| 111 | +### Create protection rules |
| 112 | + |
| 113 | +To manage changes to content within your repository, you can create [branch protection rules](https://docs.github.com/github/administering-a-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule) to enforce certain workflows for one or more branches. Protection rules that can be applied to a branch include: |
| 114 | + |
| 115 | +- Require a pull request before merging. |
| 116 | +- Require status checks to pass before merging. |
| 117 | +- Require conversation resolution before merging. |
| 118 | +- Require signed commits. |
| 119 | +- Require linear history. |
| 120 | +- Require merge queue. |
| 121 | +- Require deployments to succeed before merging. |
| 122 | +- Lock the branch by making it read-only. |
| 123 | +- Restrict who can push to matching branches. |
| 124 | + |
| 125 | +Additionally, you can set branch rules that apply to everyone, including administrators. For example, you can allow force pushes to matching branches and allow deletions from users who have push access. |
| 126 | + |
| 127 | +### Add a CODEOWNERS file |
| 128 | + |
| 129 | +By adding a [CODEOWNERS](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax) file to your repository, you can assign team members or entire teams as code owners who are responsible for code in the repository. When someone opens a pull request that modifies code that belongs to a code owner, the code owner is automatically requested as a reviewer. |
| 130 | + |
| 131 | +You can create the CODEOWNERS file in either the root of the repository or in the `docs` or `.github` folder. |
| 132 | + |
| 133 | +### View traffic by using Insights |
| 134 | + |
| 135 | +Anyone who has push access to a repository can [view its traffic](https://docs.github.com/en/repositories/viewing-activity-and-data-for-your-repository/viewing-traffic-to-a-repository). In the traffic graph, they can view full clones (not fetches), visitors from the past 14 days, referring sites, and popular content. |
| 136 | + |
| 137 | +To access the traffic graph: |
| 138 | + |
| 139 | +1. On GitHub.com, go to the main page of the repository. |
| 140 | +1. Under your repository name, select **Insights**. |
| 141 | + |
| 142 | + :::image type="content" source="../media/repository-navigation-insights-tab.png" alt-text="Screenshot showing where to locate the Insights button in GitHub."::: |
| 143 | + |
| 144 | +1. On the left, select **Traffic**. |
| 145 | + |
| 146 | + :::image type="content" source="../media/traffic-tab.png" alt-text="Screenshot showing the Traffic tab highlighted in GitHub."::: |
| 147 | + |
| 148 | +1. Optionally, you can select **Clones** or **Views** to see the traffic graph for clones or views. |
0 commit comments