auth

package
v0.0.0-...-dd01cb3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *types.User

func IsAdminContext

func IsAdminContext(ctx context.Context) bool

func NewAdminContext

func NewAdminContext(ctx context.Context) context.Context

for admin

func NewContext

func NewContext(ctx context.Context, user *types.User) context.Context

func RequireAuthMiddleware

func RequireAuthMiddleware(inner http.Handler) http.Handler

func UserInfoMiddleware

func UserInfoMiddleware(verifier jwt.Verifier) func(http.Handler) http.Handler

Types

type Handler

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

func NewHandler

func NewHandler(srv service) *Handler

func (*Handler) Auth

func (h *Handler) Auth(w http.ResponseWriter, r *http.Request)

func (*Handler) Routes

func (h *Handler) Routes() []router.Route

type Service

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

func NewService

func NewService(signer jwt.Signer, authenticator UserAuthen) *Service

func (*Service) Auth

func (s *Service) Auth(ctx context.Context, email, password string) (string, *types.User, error)

type UserAuthen

type UserAuthen interface {
	Auth(ctx context.Context, email, password string) (*types.User, error)
}

Jump to

Keyboard shortcuts

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