auth

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator added in v1.5.0

type Authenticator interface {
	ClientCredentials() (*Token, error)
	PasswordCredentials(user, password string) (*Token, error)
}

Authenticator should be implemented for different authentication strategies

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

Client should be implemented for http like clients which do automatic authentication

type Flow added in v1.6.1

type Flow string

Flow defiens an OAuth 2 authentication flow, a.k.a. grant type

const (
	// DefaultFlow is the default auth flow
	DefaultFlow Flow = ""
	// ClientCredentials flow used for technical user
	ClientCredentials Flow = "client-credentials"
	// PasswordGrant flow used for named users
	PasswordGrant Flow = "password-grant"
)

type Options

type Options struct {
	User                  string
	Password              string
	ClientID              string `mapstructure:"client_id"`
	ClientSecret          string `mapstructure:"client_secret"`
	Certificate           string `mapstructure:"cert"`
	Key                   string `mapstructure:"key"`
	AuthorizationEndpoint string `mapstructure:"authorization_endpoint"`
	TokenEndpoint         string `mapstructure:"token_endpoint"`
	IssuerURL             string `mapstructure:"issuer_url"`
	AuthFlow              Flow   `mapstructure:"auth_flow"`

	TokenBasicAuth bool `mapstructure:"token_basic_auth"`
	SSLDisabled    bool `mapstructure:"ssl_disabled"`

	Timeout time.Duration `mapstructure:"timeout"`
}

Options is used to configure new authenticators and clients

type Token

type Token struct {
	AccessToken  string    `json:"access_token"`
	TokenType    string    `json:"token_type"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresIn    time.Time `json:"expires_in"`
	Scope        string    `json:"scope"`
}

Token contains the structure of a typical UAA response token

func GetToken added in v1.5.0

func GetToken(options *Options, authenticator Authenticator) (*Token, error)

GetToken uses the provided authenticator to get a token using the appropriate flow depending on the provided options

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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