credential

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeBasicAuth = "Basic"
	AuthTypeInsecure  = "Insecure"
)
View Source
const SubjectNameAnonymous = "anonymous"

Variables

This section is empty.

Functions

func GetCredentialInitializer

func GetCredentialInitializer() map[AuthType]NewCredentialFunc

func RegisterCredentialInitializer

func RegisterCredentialInitializer(authType AuthType, initializer NewCredentialFunc)

Types

type AnonymousAuthInfo

type AnonymousAuthInfo struct{}

func (AnonymousAuthInfo) AuthType

func (a AnonymousAuthInfo) AuthType() AuthType

func (AnonymousAuthInfo) SubjectName

func (a AnonymousAuthInfo) SubjectName() string

type AuthInfo

type AuthInfo interface {
	// AuthType return the authentication protocol.
	AuthType() AuthType
	// SubjectName return the subject name it holds.
	SubjectName() string
}

AuthInfo defines the common interface for the auth information the users are interested in. A struct that implements AuthInfo can hold other information the corresponding protocol can provide besides the interface defined.

type AuthType

type AuthType string

type BasicAuthInfo

type BasicAuthInfo struct {
	Username string
	Password string
}

func (BasicAuthInfo) AuthType

func (b BasicAuthInfo) AuthType() AuthType

func (BasicAuthInfo) SubjectName

func (b BasicAuthInfo) SubjectName() string

type Credential

type Credential interface {
	// AuthType return the authentication protocol.
	AuthType() AuthType
	// Auth takes a http request parameter and uses corresponding protocol to retrieve AuthInfo from the request.
	Auth(r *http.Request) (AuthInfo, error)
	// AuthToken takes a raw token string parameter and uses corresponding protocol to retrieve AuthInfo from it.
	AuthToken(token string) (AuthInfo, error)
	// Run starts the Credential component
	Run(ctx context.Context)
}

Credential defines common interface for all authentication protocol(e.g., BasicAuth, JWT Token).

func DefaultCredential

func DefaultCredential() Credential

func GetCredential

func GetCredential(genericConf *generic.GenericConfiguration, dynamicConfig *dynamic.DynamicAgentConfiguration) (Credential, error)

func NewBasicAuthCredential

func NewBasicAuthCredential(_ *generic.AuthConfiguration, dynamicConfiguration *dynamic.DynamicAgentConfiguration) (Credential, error)

type NewCredentialFunc

type NewCredentialFunc func(authConfig *generic.AuthConfiguration, dynamicConfig *dynamic.DynamicAgentConfiguration) (Credential, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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