web

package
v0.0.0-...-32b810b Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderContentType is the name for the conten type HTTP header.
	HeaderContentType = "Content-Type"
	// HeaderContentDisposition is the name for the conten disposition HTTP header.
	HeaderContentDisposition = "Content-Disposition"
	// HeaderContentLength is the name for the conten disposition HTTP header.
	HeaderContentLength = "Content-Length"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMiddleware

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

AuthMiddleware defines which types of filters are provided by the auth middleware.

func NewAuthMiddleware

func NewAuthMiddleware(
	authService application.AuthService,
	tokenKeyResolver application.TokenKeyResolver,
) *AuthMiddleware

NewAuthMiddleware creates a new auth middleware using the given token key resolver and auth service.

func (*AuthMiddleware) Require

func (auth *AuthMiddleware) Require(filter filter) echo.MiddlewareFunc

Require defines a middleware which checks for a valid authentication token and uses to custom function to authorize the token.

func (*AuthMiddleware) RequireAdminRole

func (auth *AuthMiddleware) RequireAdminRole() echo.MiddlewareFunc

RequireAdminRole returns a middleware handler function for protecting end-points needing user authentication.

Only users having with 'admin' role are allowed to access the end-point.

func (*AuthMiddleware) RequireAuthentication

func (auth *AuthMiddleware) RequireAuthentication() echo.MiddlewareFunc

RequireAuthentication returns a middleware handler function for protecting end-points needing user authentication.

Any valid subject claim will pass the middleware.

func (*AuthMiddleware) RequireRole

func (auth *AuthMiddleware) RequireRole(requiredRoles ...string) echo.MiddlewareFunc

RequireRole returns a middleware handler function for protecting end-points needing user authentication. The authenticated user needs to have any role from the given set of roles in order to pass.

func (*AuthMiddleware) RequireScope

func (auth *AuthMiddleware) RequireScope(requiredScopes ...string) echo.MiddlewareFunc

RequireScope returns a middleware handler function for protecting end-points authentication. At least one of the given scopes needs to be granted in order to pass.

type Router

type Router interface {
	DefineRoutes(group *echo.Group, auth *AuthMiddleware)
}

Router defines an abstraction for a REST router.

func NewAuthRouter

func NewAuthRouter(
	authService application.AuthService,
	tokenKeyResolver application.TokenKeyResolver,
) Router

NewAuthRouter creates a new router for auth functionality based on the given configuration.

func NewDocumentRouter

func NewDocumentRouter(documentService application.DocumentService) Router

NewDocumentRouter creates a new router for document management using the given document service.

func NewUserRouter

func NewUserRouter(userService application.UserService) Router

NewUserRouter creates a new router for user management using the given user service.

type Server

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

Server represents the main object responsible for running the REST interface.

func NewServer

func NewServer(
	config *config.Configuration,
	authService application.AuthService,
) *Server

NewServer constructs a new server instance considering the given configuration.

func (*Server) Register

func (server *Server) Register(routers ...Router)

Register registeres the given router with all its defined routes with the given server instance.

func (*Server) Start

func (server *Server) Start() error

Start runs the server in a blocking way.

type Validator

type Validator struct {
	Validator *validator.Validate
}

Validator defines a struct for validating objects.

func (Validator) Validate

func (validator Validator) Validate(i interface{}) error

Validate validates the given object based on its constraints.

Jump to

Keyboard shortcuts

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