basic_auth

package
v0.7.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RegexPrefix = "r#"
)

Variables

This section is empty.

Functions

func CompileString

func CompileString(input string, context map[string]interface{}) (string, error)

Types

type BasicAuth

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

BasicAuth make sure the request is allowed to be sent to backend Use apache htpasswd utility for generating passwords e.g. htpasswd -nB user Middleware will look for Authorization header for credentials value should be "Basic <base64encoded user:password>"

func New

func New(logger log.Logger, next http.Handler) *BasicAuth

func (BasicAuth) Info

func (*BasicAuth) ServeHTTP

func (w *BasicAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type Config

type Config struct {
	Users []Credentials `yaml:"users" mapstructure:"users"`

	// TODO take a file instead of embedded users in yaml
	UserDB string `yaml:"userdb" mapstructure:"userdb"`

	// Scope is optional and used for additional policy based
	// authorization over user
	Scope Scope `yaml:"scope" mapstructure:"scope"`
}

type Credentials

type Credentials struct {
	User string `yaml:"user" mapstructure:"user"`

	// Password must be hashed using MD5, SHA1, or BCrypt(recommended) using htpasswd
	Password string `yaml:"password" mapstructure:"password"`

	// Capabilities are optional and used with scope for applying authz
	// Supports regular expr if marked with r# as a prefix
	Capabilities []string `yaml:"capabilities" mapstructure:"capabilities"`
}

type Scope

type Scope struct {
	Action     string                          `yaml:"action" mapstructure:"action"`
	Attributes map[string]middleware.Attribute `yaml:"attributes" mapstructure:"attributes"` // auth field -> Attribute
}

Jump to

Keyboard shortcuts

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