auth_router

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register[Req proto.Message, Res proto.Message, A interface{}](
	m *Module[A],
	pathSpec string,
	handler func(auth *A, par router.Params, reqpb Req) (Res, error),
	authenticators ...users.Authenticator,
)

Types

type Module

type Module[AuthSession interface{}] struct {
	Logger *logger.Module
	Config *config.Module
	Router *router.Module
	Auth   *users.Module

	// RequireAuth runs before all Register routes in this module (not Public routes) Use this to
	// parse an auth session from the request. Override authenticators may be passed via the
	// variadic authenticators argument
	RequireAuth func(router.Handle, ...users.Authenticator) router.Handle

	// GetAuthSession is use to pull an AuthSession (ideally provided by RequireAuth above) out of
	// the request context. Note that nil auth sessions are okay; if you want to require an auth
	// session, implement GetAuthSession to throw an ErrNotAuthorized when your auth session is nil
	GetAuthSession func(req *http.Request) (*AuthSession, error)
	// contains filtered or unexported fields
}

Module router implements basic routing with helpers for protobuf-rootd responses.

func (*Module[A]) Init

func (m *Module[A]) Init(c *service.Config)

Init implements service.Init

func (*Module[A]) Public

func (m *Module[A]) Public(pathSpec string, h router.Handle)

POST is a shortcut for m.Router.POST. NOT authed by default

func (*Module[A]) PublicDELETE

func (m *Module[A]) PublicDELETE(path string, h router.Handle)

DELETE is a shortcut for m.Router.DELETE. NOT authed

func (*Module[A]) PublicGET

func (m *Module[A]) PublicGET(path string, h router.Handle)

GET is a shortcut for m.Router.GET. NOT authed

func (*Module[A]) PublicPATCH

func (m *Module[A]) PublicPATCH(path string, h router.Handle)

PATCH is a shortcut for m.Router.PATCH. NOT authed

func (*Module[A]) PublicPOST

func (m *Module[A]) PublicPOST(path string, h router.Handle)

POST is a shortcut for m.Router.POST. NOT authed

func (*Module[A]) PublicPUT

func (m *Module[A]) PublicPUT(path string, h router.Handle)

PUT is a shortcut for m.Router.PUT. NOT authed

type Route

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

Jump to

Keyboard shortcuts

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