basic

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHTPasswd

func ParseHTPasswd(rd io.Reader) (map[string][]byte, error)

ParseHTPasswd parses the contents of htpasswd. This will read all the entries in the file, whether or not they are needed. An error is returned if a syntax errors are encountered or if the reader fails. Cherry-picked and modified from https://github.com/distribution/distribution/blob/v2.7.1/registry/auth/htpasswd/htpasswd.go

func SplitBasicCred

func SplitBasicCred(c string) (user string, password string, err error)

SplitBasicCred splits input string with htpasswd format. Input string is separated with colon and validated as slice which has length 2. If the length of result of split is not 2, it returns error.

Types

type Authenticator

type Authenticator struct {
	Logger []io.Writer //log writer set
	// contains filtered or unexported fields
}

Authenticator is auth.Provider implementation for basic authentication.

func NewBasicAuth

func NewBasicAuth(cred string, logger ...io.Writer) (*Authenticator, error)

NewBasicAuth generates new filter instance for basic authentication.

func (*Authenticator) Authenticate

func (b *Authenticator) Authenticate(handler http.HandlerFunc, _ ...string) http.HandlerFunc

func (Authenticator) Log

func (b Authenticator) Log(logLine string)

Log provides internal logging mechanism for Authenticator

func (*Authenticator) RouterAuthenticate

func (b *Authenticator) RouterAuthenticate(handle httprouter.Handle, _ ...string) httprouter.Handle

RouterAuthenticate handles authentication process via Basic authentication. If any unauthorized access, it sends WWW-RouterAuthenticate header for the client and terminate the session.

Jump to

Keyboard shortcuts

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