httpauth

package
v0.0.0-...-a5f7211 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteLoginCookie

func DeleteLoginCookie() *http.Cookie

func GenerateKey

func GenerateKey() ([]byte, []byte, error)

func ToCookie

func ToCookie(tokenString string) *http.Cookie

func ToCookiesWithCsrfProtection

func ToCookiesWithCsrfProtection(tokenString string) []*http.Cookie

Types

type HttpRequestAuthenticator

type HttpRequestAuthenticator interface {
	// authenticates a Request
	Authenticate(req *http.Request) (*UserDetails, error)
	AuthenticateJwtString(jwtString string) (*UserDetails, error)
	// authenticates a Request that has cookies returned by ToCookiesWithCsrfProtection()
	AuthenticateWithCsrfProtection(req *http.Request) (*UserDetails, error)
}

func NewEcJwtAuthenticator

func NewEcJwtAuthenticator(validatorPublicKey []byte) (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, now time.Time) string
}

func NewEcJwtSigner

func NewEcJwtSigner(privateKey []byte) (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