1Password / shell-plugins

Seamless authentication for every tool in your terminal.
https://developer.1password.com/docs/cli/shell-plugins/
MIT License
527 stars 172 forks source link

Add support for GitHub enterprise #137

Open hculea opened 1 year ago

hculea commented 1 year ago

Platform or tool

GitHub

Desired or expected behavior

The GitHub plugin should ensure that the GitHub CLI can talk to a custom host, when the user uses GitHub Enterprise.

Possible solutions:

  1. When used with Github Enterprise, the GitHub CLI expects a GH_ENTERPRISE_TOKEN envvar rather than GH_TOKEN. User should be able to opt for overriding the default envvar by the enterprise-specific one.
  2. Based on the GitHub host, shell plugins could determine whether GitHub enterprise is used and to inject the GH_ENTERPRISE_TOKEN envvar instead without any extra config required from the user.

Current behavior

GH_TOKEN always gets injected, regardless of what GH_HOST is.

Relevant log output

No response

op CLI version

No response

dvanoni commented 1 year ago

Thanks for creating this issue, @hculea!

To refine this a bit, I think it would also be valid to inject both GH_TOKEN and GH_ENTERPRISE_TOKEN. I believe this would allow you to authenticate with both github.com as well as an enterprise server.

datalogics-kam commented 1 year ago

To refine this a bit, I think it would also be valid to inject both GH_TOKEN and GH_ENTERPRISE_TOKEN. I believe this would allow you to authenticate with both github.com as well as an enterprise server.

We do have this specific need, to be able to authenticate to both github.com and our enterprise server.

It would be really useful if it were automatic and not treated like "separate accounts", where I have to partition all my existing work to be in separate "github.com" and "enterprise" subtrees.

Maybe it could detect from the remote in the git repository (if present) or the arguments to gh?

jnials commented 1 year ago

I only need to login to enterprise, but it's pretty much a requirement.