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 ¶
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 ¶
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 ¶
WithDeniedHandler selects denial handling; nil preserves the default 403 response.
func WithErrorHandler ¶
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.