basicauth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCAuthFunc

func GRPCAuthFunc(checker *Checker) func(ctx context.Context) (context.Context, error)

GRPCAuthFunc creates grpc_auth.AuthFunc. It does authentication using the basic auth scheme, and validates any user/password sent using checker.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker stores a set of valid credentials to be used when authenticating HTTP requests using basic auth.

func NewChecker

func NewChecker(credentials []Credential) *Checker

NewChecker returns a basic auth checker configured to use credentials when checking for valid authentication.

func (*Checker) Authenticate

func (c *Checker) Authenticate(metricsProvider metrics.Provider) func(handler http.Handler) http.Handler

Authenticate creates a middleware style HTTP handler that enforces valid basic auth credentials before allowing a request to continue to handler.

func (*Checker) Valid

func (c *Checker) Valid(username, password string) bool

Valid is true if username and password represent acceptable credentials.

type Credential

type Credential struct {
	Username string
	Password string
}

Credential is a valid username/password pair used to authenticate HTTP requests using basic auth.

type Credentials

type Credentials []Credential

Credentials is a set of credentials with the added functionality of decoding.

func (*Credentials) Decode

func (c *Credentials) Decode(repl string) error

Decode implements the envdecode contract, allowing Credentials to be used in config structs.

type GRPCCredentials

type GRPCCredentials struct {
	Username, Password string

	TransportSecurity bool
}

GRPCCredentials implements PerRPCCredentials.

func (GRPCCredentials) GetRequestMetadata

func (c GRPCCredentials) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error)

GetRequestMetadata maps the given credentials to the appropriate request headers.

func (GRPCCredentials) RequireTransportSecurity

func (c GRPCCredentials) RequireTransportSecurity() bool

RequireTransportSecurity implements PerRPCCredentials.

Jump to

Keyboard shortcuts

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