auth

package
v0.89.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvHCPCredFile is the environment variable that sets the HCP Credential
	// File location.
	EnvHCPCredFile = "HCP_CRED_FILE"

	// CredentialFileName is the file name for the HCP credential file.
	CredentialFileName = "cred_file.json"

	// CredentialFileSchemeServicePrincipal is the credential file scheme value
	// that indicates service principal credentials should be used to
	// authenticate to HCP.
	CredentialFileSchemeServicePrincipal = "service_principal_creds"

	// CredentialFileSchemeWorkload is the credential file scheme value
	// that indicates workload identity credentials should be used to
	// authenticate to HCP.
	CredentialFileSchemeWorkload = "workload"
)

Variables

This section is empty.

Functions

func GetCredentialFilePath added in v0.58.0

func GetCredentialFilePath() (string, error)

GetCredentialFilePath returns the credential file path, first looking for an overriding environment variable and then falling back to the default file location.

func NewBrowserLogin added in v0.71.0

func NewBrowserLogin(oauthConfig *oauth2.Config) *browserLogin

NewBrowserLogin will return an oauth2.TokenSource that will return a Token from an interactive browser login.

func WriteCredentialFile added in v0.57.0

func WriteCredentialFile(path string, cf *CredentialFile) error

WriteCredentialFile writes the given credential file to the path.

func WriteDefaultCredentialFile added in v0.57.0

func WriteDefaultCredentialFile(cf *CredentialFile) error

WriteDefaultCredentialFile writes the credential file to the default credential file location or to the value of EnvHCPCredFile if set.

Types

type CredentialFile added in v0.57.0

type CredentialFile struct {
	// ProjectID captures the project ID of the service principal. It may be blank.
	ProjectID string `json:"project_id,omitempty"`

	// Scheme is the authentication scheme. It may be one of: service_principal_creds, workload.
	Scheme string `json:"scheme,omitempty"`

	// Workload configures the workload identity provider to exchange tokens
	// with.
	Workload *workload.IdentityProviderConfig `json:"workload,omitempty"`

	// Oauth configures authentication via Oauth.
	Oauth *OauthConfig `json:"oauth,omitempty"`
}

CredentialFile stores information required to authenticate to HCP APIs. It supports various authentication schemes, such as service principal

func GetDefaultCredentialFile added in v0.57.0

func GetDefaultCredentialFile() (*CredentialFile, error)

GetDefaultCredentialFile returns the credential file by searching the default credential file location or by using the credential file environment variable to look for an override. If no credential file is found, a nil value will be returned with no error set.

func ReadCredentialFile added in v0.57.0

func ReadCredentialFile(path string) (*CredentialFile, error)

ReadCredentialFile returns the credential file at the given path.

func (*CredentialFile) Validate added in v0.57.0

func (c *CredentialFile) Validate() error

Validate validates the CredentialFile

type OauthConfig added in v0.57.0

type OauthConfig struct {
	// ClientID is the client id of an HCP Service Principal
	ClientID string `json:"client_id,omitempty"`

	// ClientSecret is the client secret of an HCP Service Principal
	ClientSecret string `json:"client_secret,omitempty"`
}

OauthConfig configures authentication based on OAuth credentials.

func (*OauthConfig) Validate added in v0.57.0

func (o *OauthConfig) Validate() error

Validate validates the OauthConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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