auth

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	// Returns the bearer token or an error
	Token() (*oauth2.Token, error)
	Client(ctx context.Context) *http.Client
}

The authenticator manages the oauth authentication to the bol API

func New

func New(provider CredentialProvider) (Authenticator, error)

Creates a new instance of the Authenticator using the credentials from the provider.

func NewWithTokenEndpoint

func NewWithTokenEndpoint(provider CredentialProvider, tokenEndpoint string) (Authenticator, error)

type BasicProvider

type BasicProvider struct {
	ClientIdVal string
	UsernameVal string
	PasswordVal string
	TenantVal   string
}

Simple raw value credential provider

func (*BasicProvider) ClientId

func (p *BasicProvider) ClientId() (string, error)

func (*BasicProvider) Password

func (p *BasicProvider) Password() (string, error)

func (*BasicProvider) Tenant

func (p *BasicProvider) Tenant() (string, error)

func (*BasicProvider) Username

func (p *BasicProvider) Username() (string, error)

type CredentialProvider

type CredentialProvider interface {
	// oauth clientID (see AAD app registry)
	ClientId() (string, error)
	// username of admin
	Username() (string, error)
	// password of admin
	Password() (string, error)
	// The tenant id (see AAD app registry)
	Tenant() (string, error)
}

The credentials to communicate with the bc API.

type EnvironmentProvider

type EnvironmentProvider struct {
	ClientIdKey string
	UsernameKey string
	PasswordKey string
	TenantKey   string
}

Fetches the credentials from the environment

func NewEnvProvider

func NewEnvProvider() *EnvironmentProvider

func (*EnvironmentProvider) ClientId

func (p *EnvironmentProvider) ClientId() (string, error)

func (*EnvironmentProvider) Password

func (p *EnvironmentProvider) Password() (string, error)

func (*EnvironmentProvider) Tenant

func (p *EnvironmentProvider) Tenant() (string, error)

func (*EnvironmentProvider) Username

func (p *EnvironmentProvider) Username() (string, error)

type FileProvider

type FileProvider struct {
	// The directory with the files, this is usually the place where you mount the secret volume
	Dir string // Should equal /etc/secrets

	// The filename within Dir containing the ClientId
	ClientIdFile string // Should equal "clientId"

	// The filename within Dir containing the username
	UsernameFile string // Should equal "username"

	// The filename within Dir containing the password
	PasswordFile string // Should equal "password"

	// The filename within Dir containing the AAD tenantId
	TenantFile string
}
By default we use a FileProvider. This allows us to mount a kubernetes secret into the container.
The mounted volume will create two files containing the clientId and clientSecret
The FileProvider is responsible for reading them.

CredentialProvider implementation for a dir containing two files, each containing the secret as a string.

func NewFileProvider

func NewFileProvider() *FileProvider

func (*FileProvider) ClientId

func (p *FileProvider) ClientId() (string, error)

func (*FileProvider) Password

func (p *FileProvider) Password() (string, error)

func (*FileProvider) Tenant

func (p *FileProvider) Tenant() (string, error)

func (*FileProvider) Username

func (p *FileProvider) Username() (string, error)

Jump to

Keyboard shortcuts

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