jupyterhub / gh-scoped-creds

Provide fine-grained push access to GitHub from a JupyterHub
BSD 3-Clause "New" or "Revised" License
25 stars 7 forks source link

Support lib for internal Git servers #64

Open aksylumoed opened 1 month ago

aksylumoed commented 1 month ago

Proposed change

The lib defaults to using github.com (ref) as the domain name to look for the authentication, but could be extended to support internal git servers (GH enterprise users) as well.

The default github.com domain cannot find any Github Apps that are created on an internal Git server, so a 404 error is thrown as the client Id cannot be found.

Alternative options

There's no current alternative I could think of; anyone wanting to make changes to repos in internal Git servers via Jhub cannot use this lib as it only supports github.com. We could maintain a forked version of this lib, but IMO it would be difficult to keep track of any future changes.

Who would use this feature?

This feature would be useful for all Gtihub Enterprise users who'd like to use this lib for getting access to internal Git servers.

(Optional): Suggest a solution

(I have tested this solution for our internal Git server to verify)

We can introduce another arg --hostname (or equivalent) to specify the which internal Git domain should be used. If not specified, it can default github.com. Similar to the other args, an env var GH_SCOPED_CREDS_HOSTNAME can be specified to avoid passing this arg every time.

This arg would then be used in all the places where "github.com" is being hardcoded:

  1. https://github.com/jupyterhub/gh-scoped-creds/blob/main/gh_scoped_creds/__init__.py#L22
  2. https://github.com/jupyterhub/gh-scoped-creds/blob/main/gh_scoped_creds/__init__.py#L51
  3. https://github.com/jupyterhub/gh-scoped-creds/blob/main/gh_scoped_creds/__init__.py#L94
  4. https://github.com/jupyterhub/gh-scoped-creds/blob/main/gh_scoped_creds/__init__.py#L103
aksylumoed commented 1 month ago

cc @yuvipanda as you're the top contributor to this repo.

Any concerns if I make a PR for this change? I have the changes already locally, would just need write access to make a PR.