echobasicauth

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

README

echo basic auth

Basic Auth middleware with constant time equality checks and optional IP whitelisting for Echo framework

Usage

auth := &echobasicauth.Auth{Login: "test", Password: "test", IPs: []string{"127.0.0.1"}}
e.Use(echobasicauth.NewMiddleware(auth))
// or you can use echobasicauth.NewValidator(auth) if you want to define the middleware yourself

Documentation

Index

Constants

View Source
const ContextLoginKey = "echo-basic-auth.login"

ContextLoginKey is the key used to store the login after successful auth in the context

Variables

This section is empty.

Functions

func Equals

func Equals(str1, str2 string) bool

Equals performs equality check in constant time

func NewMiddleware

func NewMiddleware(auths ...*Auth) echo.MiddlewareFunc

NewMiddleware returns a new BasicAuth middleware instance

func NewValidator

func NewValidator(auths ...*Auth) middleware.BasicAuthValidator

NewValidator returns a new BasicAuthValidator

Types

type Auth

type Auth struct {
	Login    string   `json:"login" yaml:"login"`       // Basic auth login
	Password string   `json:"password" yaml:"password"` // Basic auth password
	IPs      []string `json:"ips" yaml:"ips"`           // Allowed IPs
}

Auth model

Jump to

Keyboard shortcuts

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