Documentation ¶
Overview ¶
Package auth is a set of functions for retrieving authentication tokens and authenticated hosts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHost ¶
DefaultHost retrieves an authenticated host and the source of host. The source can be either an environment variable or from the configuration file. Returns "github.com", "default" if no viable host is found.
func IsEnterprise ¶ added in v2.9.0
IsEnterprise determines if a provided host is a GitHub Enterprise Server instance, rather than GitHub.com or a tenancy GitHub instance.
func IsTenancy ¶ added in v2.9.0
IsTenancy determines if a provided host is a tenancy GitHub instance, rather than GitHub.com or a GitHub Enterprise Server instance.
func KnownHosts ¶
func KnownHosts() []string
KnownHosts retrieves a list of hosts that have corresponding authentication tokens, either from environment variables or from the configuration file. Returns an empty string slice if no hosts are found.
func NormalizeHostname ¶ added in v2.11.0
NormalizeHostname ensures the host matches the values used throughout the rest of the codebase with respect to hostnames. These are github, localhost, and tenancyHost.
func TokenForHost ¶
TokenForHost retrieves an authentication token and the source of that token for the specified host. The source can be either an environment variable, configuration file, or the system keyring. In the latter case, this shells out to "gh auth token" to obtain the token.
Returns "", "default" if no applicable token is found.
func TokenFromEnvOrConfig ¶
TokenFromEnvOrConfig retrieves an authentication token from environment variables or the config file as fallback, but does not support reading the token from system keyring. Most consumers should use TokenForHost.
Types ¶
This section is empty.