asgard

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package asgard provides middleware for use in HTTP API servers. In Norse mythology, Heimdallr is the gatekeeper of Bifröst.

Heimdallr returna a HTTP Handler middleware function that parses a header for authentication information. On success, it stores an Identity in the request context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Heimdallr

func Heimdallr(namespace uuid.UUID) func(http.Handler) http.Handler

Heimdallr returns a HTTP Handler middleware function that parses an AuthorizedRequestContext from the request context header. If namespace does not match the parsed one, the request is forbidden. The AuthorizedRequestContext is stored in the request context.

If Heimdallr is used in an AWS Lambda Web Adapter powered API server, Bouncer Lambda Authorizer must be configured as an authorizer for the API Gateway method.

Types

type Identity

type Identity struct {
	Namespace uuid.UUID
	PublicKey *ecdsa.PublicKey
	SourceIp  string
	UserAgent string
}

func FromContext

func FromContext(ctx context.Context) (*Identity, bool)

FromContext returns an Identity from the request context. If the request context does not contain an AuthorizedRequestContext, the second return value is false.

func MustFromContext

func MustFromContext(ctx context.Context) *Identity

MustFromContext is like FromContext but panics if the request context does not contain an AuthorizedRequestContext.

Jump to

Keyboard shortcuts

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