auth

package
v2.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 8 Imported by: 75

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

func DefaultHost() (string, string)

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

func IsEnterprise(host string) bool

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

func IsTenancy(host string) bool

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

func NormalizeHostname(host string) string

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

func TokenForHost(host string) (string, string)

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

func TokenFromEnvOrConfig(host string) (string, string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL