httpauth

package
v0.0.0-...-831b668 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpired = errors.New("auth: session expired")
	ErrNoAuthToken  = errors.New("auth: either specify '" + loginCookieName + "' cookie or 'Authorization' header")
)

Functions

func DeleteLoginCookie

func DeleteLoginCookie() *http.Cookie

func ToCookie

func ToCookie(tokenString string) *http.Cookie

Types

type HttpRequestAuthenticator

type HttpRequestAuthenticator interface {
	// authenticates a Request. error is ErrNoAuthToken if no auth details and ErrSessionExpired if auth token expired
	Authenticate(req *http.Request) (*UserDetails, error)
	AuthenticateJwtString(jwtString string) (*UserDetails, error)
}

func NewJwtAuthenticator

func NewJwtAuthenticator(publicKey ed25519.PublicKey, audience string) (HttpRequestAuthenticator, error)

type MiddlewareChain

type MiddlewareChain func(w http.ResponseWriter, r *http.Request) *RequestContext

if returns nul, request handling is aborted. in return=nil case middleware is responsible for error response.

type MiddlewareChainMap

type MiddlewareChainMap map[string]MiddlewareChain

type RequestContext

type RequestContext struct {
	User *UserDetails
}

type Signer

type Signer interface {
	Sign(userDetails UserDetails, audience string, now time.Time) string
}

func NewJwtSigner

func NewJwtSigner(privKey ed25519.PrivateKey) (Signer, error)

type UserDetails

type UserDetails struct {
	Id           string
	AuthTokenJwt string // the JWT token that was used for auth
}

func NewUserDetails

func NewUserDetails(id string, authTokenJwt string) *UserDetails

Jump to

Keyboard shortcuts

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