Skip to content

RFC 113: Implement `PermsFetcher` interface for GitHub authz provider

Created by: unknwon

Essentially, add two methods to GitHub authz provider: enterprise/cmd/frontend/internal/authz/github

https://github.com/sourcegraph/sourcegraph/blob/21ebcf76705dff32b5c6573de65e12ab9c5a112d/enterprise/cmd/repo-updater/authz/perms_syncer.go#L45-L62

An example implementation for GitLab can be found at https://github.com/sourcegraph/sourcegraph/blob/master/enterprise/cmd/frontend/internal/authz/gitlab/sudo.go

Things to note

  1. Return partial but valid results whenever possible.
  2. When fetch in user-centric:
    1. Use token extracted from github.GetExternalAccountData(&userAccount.ExternalAccountData).
    2. The GraphQL node ID as the extsvc.ExternalAccountID for results.
    3. The API is same as what we use for RepoPerms today.
  3. When fetch in repo-centric:
    1. Use the admin token configured in external service.
    2. The GraphQL node ID as the extsvc.ExternalRepoID for results.
    3. API example (login is not required, just for debugging):
    {
      repository(name: "sourcegraph", owner: "sourcegraph") {
        id
        collaborators(affiliation: ALL) {
          edges {
            node {
              id
              login
            }
          }
          pageInfo {
            endCursor
            hasNextPage
          }
        }
      }
    }

Let me know when you have any questions!