handlers

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package handlers contains custom handler functions

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadRequest is returned when the request cannot be processed
	ErrBadRequest = errors.New("invalid request")

	// ErrMissingRequiredFields is returned when the login request has an empty username or password
	ErrMissingRequiredFields = errors.New("invalid request, missing username and/or password")
)

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(ctx context.Context) error

CheckFunc is a function that can be used to check the status of a service

type Checks

type Checks struct {
	// contains filtered or unexported fields
}

func (*Checks) ReadyHandler

func (c *Checks) ReadyHandler(ctx echo.Context) error

type Handler

type Handler struct {
	// DBClient to interact with the generated ent schema
	DBClient *ent.Client
	// TM contains the token manager in order to validate auth requests
	TM *tokens.TokenManager
	// CookieDomain is the domain set in cookie for authenticated requests, defaults to datum.net
	CookieDomain string
	// Logger provides the zap logger to do logging things from the handlers
	Logger *zap.SugaredLogger
	// ReadyChecks is a set of checkFuncs to determine if the application is "ready" upon startup
	ReadyChecks Checks
	// JWTKeys contains the set of valid JWT authentication key
	JWTKeys jwk.Set
}

Handler contains configuration options for handlers

func (*Handler) AddReadinessCheck

func (h *Handler) AddReadinessCheck(name string, f CheckFunc)

AddReadinessCheck will accept a function to be ran during calls to /readyz These functions should accept a context and only return an error. When adding a readiness check a name is also provided, this name will be used when returning the state of all the checks

func (*Handler) JWKSWellKnownHandler

func (h *Handler) JWKSWellKnownHandler(ctx echo.Context) error

JWKSWellKnownHandler provides the JWK used to verify all Datum-issued JWTs

func (*Handler) LoginHandler

func (h *Handler) LoginHandler(ctx echo.Context) error

LoginHandler validates the user credentials and returns a valid cookie this only supports username password login today (not oauth)

func (*Handler) RefreshHandler

func (h *Handler) RefreshHandler(ctx echo.Context) error

RefreshHandler allows users to refresh their access token using their refresh token.

type RefreshRequest

type RefreshRequest struct {
	RefreshToken string `json:"refresh_token"`
}

type Response

type Response struct {
	Message string `json:"message"`
}

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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