httpauth

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package httpauth provides the legacy fail-closed net/http authorization integration.

Deprecated: use github.com/faustbrian/go-authorization/v3/adapters/http. This package remains supported for the longer of 180 days after successor public availability and two subsequently published stable root-module minor releases.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilAuthorizer preserves the direct adapter error identity for errors.Is.
	ErrNilAuthorizer = adapter.ErrNilAuthorizer
	// ErrNilRequestMapper preserves the direct adapter error identity for errors.Is.
	ErrNilRequestMapper = adapter.ErrNilRequestMapper
	// ErrNilNextHandler preserves the direct adapter error identity for errors.Is.
	ErrNilNextHandler = adapter.ErrNilNextHandler
)

Functions

func DecisionFromContext

func DecisionFromContext(ctx context.Context) (authorization.Decision, bool)

DecisionFromContext returns the attached decision by value; its slices remain shared.

func ErrorFromContext

func ErrorFromContext(ctx context.Context) (error, bool)

ErrorFromContext returns raw mapper/evaluator error state for a protected local handler.

func NewHandler

func NewHandler(
	authorizer Authorizer,
	mapper RequestMapper,
	next http.Handler,
	handlerOptions ...Option,
) (http.Handler, error)

NewHandler maps each HTTP request, evaluates it, and invokes next only for explicit allow decisions. Mapper and evaluation failures use the error handler; deny and not-applicable outcomes use the denial handler.

Types

type Authorizer

type Authorizer interface {
	// Decide returns a valid outcome or error; map errors to failure, never allow.
	Decide(context.Context, authorization.Request) (authorization.Decision, error)
}

Authorizer decides from trusted caller-mapped input. Implementations must cooperate with ctx and support concurrent reuse; this seam performs no authentication.

type Option

type Option func(*options)

Option configures construction synchronously; nil/custom options may panic.

func WithDeniedHandler

func WithDeniedHandler(handler http.Handler) Option

WithDeniedHandler selects denial handling; nil preserves the default 403 response.

func WithErrorHandler

func WithErrorHandler(handler http.Handler) Option

WithErrorHandler selects failure handling; nil preserves the default 500 response.

type RequestMapper

type RequestMapper func(*http.Request) (authorization.Request, error)

RequestMapper maps trusted HTTP identity/scope/facts synchronously; authenticate upstream and do not trust client tenant/ownership claims.

Jump to

Keyboard shortcuts

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