Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip keyring for auth check #7169

Merged
merged 11 commits into from Mar 17, 2023
14 changes: 14 additions & 0 deletions internal/config/config.go
Expand Up @@ -234,6 +234,20 @@ func (c *AuthConfig) Logout(hostname string) error {
return ghConfig.Write(c.cfg)
}

// IsEnterprise checks if there are any environment variable authentication
// tokens set for enterprise hosts.
func (c *AuthConfig) IsEnterprise() bool {
// Any non-github.com hostname is fine here
dummyHostname := "example.com"
var token string
if c.tokenOverride != nil {
token, _ = c.tokenOverride(dummyHostname)
} else {
token, _ = ghAuth.TokenFromEnvOrConfig(dummyHostname)
}
return token != ""
}
benjlevesque marked this conversation as resolved.
Show resolved Hide resolved

func keyringServiceName(hostname string) string {
return "gh:" + hostname
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/cmdutil/auth_check.go
Expand Up @@ -14,12 +14,7 @@ func DisableAuthCheck(cmd *cobra.Command) {
}

func CheckAuth(cfg config.Config) bool {
// This will check if there are any environment variable
// authentication tokens set for enterprise hosts.
// Any non-github.com hostname is fine here
dummyHostname := "example.com"
token, _ := cfg.Authentication().Token(dummyHostname)
if token != "" {
if cfg.Authentication().IsEnterprise() {
return true
}

Expand Down