wellcomecollection / platform

Wellcome Collection Digital Platform
https://developers.wellcomecollection.org/
MIT License
48 stars 10 forks source link

Enforce SSO for our GitHub organisation #5740

Open kenoir opened 9 months ago

kenoir commented 9 months ago

We now have a GitHub enterprise supported account, we should take advantage of SSO.

We will need to:

kenoir commented 9 months ago

Pausing work for a sprint to allow users to adopt, other feature work to proceed.

pollecuttn commented 7 months ago

@kenoir I think this is completed, isn't it? Can this be closed?

kenoir commented 7 months ago

@kenoir I think this is completed, isn't it? Can this be closed?

Not yet, we still have weco-bot. We could schedule some work next sprint to look at this again.

jamieparkinson commented 6 months ago

What is weco-bot?

weco-bot is a machine user on GitHub that we use for a variety of automated actions. I believe this list to be exhaustive:

How does it interact with GitHub?

weco-bot's current actions are achieved through 3 mechanisms:

  1. Use of the git client to commit with the authorship email associated with weco-bot (wellcomedigitalplatform@wellcome.ac.uk) and to push using an SSH key for the weco-bot account.
  2. Use of the GitHub API with a personal access token for the weco-bot account, to create and label PRs.
  3. Use of the Docusaurus CLI to push to GitHub for GitHub Pages deployment, options documented here.

That is to say that weco-bot's identity is assumed by our CI servers using either:

  1. An SSH key - for Buildkite agents, this is stored in an S3 bucket that is automatically accessed by the Elastic CI Stack instances.
  2. A personal access token - tokens for various actions are stored in Secret Manager.

How can we use a GitHub app instead?

Authenticating as an app installation is appropriate for all of these use cases.

While this seems straightforward, the mechanics of getting the access token in the right place are really quite complex. To get an installation access token, a machine first needs access to the app's private key in order to create a signed JWT with which to request the token.

My guess at a minimal implementation would involve something like the following:

This is quite achievable but not trivial - are we sure that the benefits of enforcing SSO outweigh the complexity/risk involved in this solution? There is of course an alternative approach where SSO is enforced and we create a machine user identity in Azure AD - is that a better solution?

rcantin-w commented 1 month ago

@agnesgaroux to have a look whether or not this can be closed/create new tickets if needed.

agnesgaroux commented 1 month ago

TO DO

kenoir commented 1 month ago

The final part of this is migrating from Buildkite to GitHub actions so the weco-bot credentials are not required to allow that build system to check out from GitHub.

See https://github.com/wellcomecollection/platform/issues/5783