credentials

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 8

Documentation

Index

Constants

View Source
const ApiTokenHeaderKey = "Authorization"
View Source
const ApiTokenHeaderValuePrefix = "Bearer"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ApiToken                        string `json:"apiToken,omitempty"`
	ClientCredentialsApiTokenIssuer string `json:"apiTokenIssuer,omitempty"`
	ClientCredentialsApiAudience    string `json:"apiAudience,omitempty"`
	ClientCredentialsClientId       string `json:"clientId,omitempty"`
	ClientCredentialsClientSecret   string `json:"clientSecret,omitempty"`
	ClientCredentialsScopes         string `json:"scopes,omitempty"`
}

type Credentials

type Credentials struct {
	Method  CredentialsMethod `json:"method,omitempty"`
	Config  *Config           `json:"config,omitempty"`
	Context context.Context
}

func NewCredentials

func NewCredentials(config Credentials) (*Credentials, error)

func (*Credentials) GetApiTokenHeader

func (c *Credentials) GetApiTokenHeader() *HeaderParams

func (*Credentials) GetHttpClientAndHeaderOverrides

func (c *Credentials) GetHttpClientAndHeaderOverrides() (*http.Client, []*HeaderParams)

GetHttpClientAndHeaderOverrides The main export the client uses to get a configuration with the necessary httpClient and header overrides based on the chosen credential method

func (*Credentials) ValidateCredentialsConfig

func (c *Credentials) ValidateCredentialsConfig() error

type CredentialsMethod

type CredentialsMethod string

Available credential methods

const (
	// No credentials (default)
	CredentialsMethodNone CredentialsMethod = "none"
	// API Token credentials (will be sent in "Authorization: Bearer $TOKEN" header)
	CredentialsMethodApiToken CredentialsMethod = "api_token"
	// Client Credentials flow will be performed, resulting token will be sent in "Authorization: Bearer $TOKEN" header
	CredentialsMethodClientCredentials CredentialsMethod = "client_credentials"
)

type HeaderParams

type HeaderParams struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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