Video in progress

Staff 🌿 Git

In an organization with hundreds of developers and outside contractors, how do you structure repo access, and what do you do when an employee leaves?

Permissions go not to people but to teams synced from SSO, and the default is the minimum (a contractor gets only the repos they need). If an employee leaves, one deletion in the IdP closes the account, SSH keys and tokens. But I also account for the fact that code that has been cloned cannot be taken back.

📖 Answer

The typical situation: for years permissions were granted by hand, there are 40 "outside collaborators", half of whom stopped working a year ago, and the personal token of a departed employee still works in CI.

The structure:

  • SSO and automatic provisioning (SCIM). The account is created and deleted in the IdP, and team membership on the platform comes from IdP groups;
  • Permission by team. The base permission is nothing or read only, and write access goes to the domain team. In critical repos (payments, auth), even read is restricted;
  • Contractors. A separate group, access with an end date, only the repos they need. Forking private repos is turned off;
  • Machine identity. CI and bots work not with a personal token but with a GitHub App or a service account owned by the team. Otherwise when a person leaves, the pipelines stop, or, worse, keep running;
  • Tokens and keys. Expiring fine-grained tokens, and short-lived SSH certificates where possible. Non-expiring classic tokens are banned by organization policy.

When an employee leaves (offboarding), this is what I do:

  1. Delete in the IdP, which automatically closes platform access and the tokens tied to SSO;
  2. rotate the secrets they know (the prod DB, external API keys). This is not Git, but it matters most;
  3. check the deploy keys, webhooks and bot integrations in their name;
  4. review the audit log for unusual mass clones in the last weeks.

The honest part: a developer sees the code, so they can copy it. Git cannot stop this. That is why security rests not on the assumption that "the code is secret" but on the rule that "there are no secrets in the code": secrets are in a secret manager, so even if the code leaks, there is no access to the system.