httpauth

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httpauth handles HTTP Basic authentication with supplied authentication functions

Index

Constants

This section is empty.

Variables

View Source
var ErrBasicAuthInvalid = errors.New("basic auth invalid")

ErrBasicAuthInvalid is returned when the basic authentication is invalid (missing header, invalid request, etc).

Functions

func GetBasicAuthFromRequest

func GetBasicAuthFromRequest(r *http.Request) (string, string, error)

GetBasicAuthFromRequest returns basic auth username and password given a `*http.Request`.

Types

type AuthProvider

type AuthProvider func(username string, password string, r *http.Request) (string, bool)

AuthProvider is a function that given a username, password and request, authenticates the user.

type BasicAuthHandler

type BasicAuthHandler struct {
	Handler     http.Handler
	RemoveAuth  bool
	BypassPaths []string

	*BasicAuthWrapper
}

BasicAuthHandler is a http.Handler that uses BasicAuthWrapper to provide basic authentication support.

func (*BasicAuthHandler) ServeHTTP

func (b *BasicAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP Satisfies the http.Handler interface for basicAuth.

type BasicAuthWrapper

type BasicAuthWrapper struct {
	Cache               *cache.Cache
	Realm               string
	Logger              *zap.Logger
	AuthFunc            AuthProvider
	UnauthorizedHandler http.Handler
	CacheDuration       time.Duration
}

BasicAuthWrapper provides a wrapper that can authenticate using basic auth headers.

Jump to

Keyboard shortcuts

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