middleware

package
v0.1.14-beta46 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package middleware (logger) provides a simple middleware for the logger.Manager. Any provider can be used. The logged information is remoteAddr, HTTP Method, URL, Proto, HTTP Status, Response size and requested time. On HTTP status < 400 an info will be logged otherwise an error. The logger middleware should used before all other middlewares.

Package middleware (rbac) provides a role based access control list. It is build on top of the JWT middleware. A RoleService must be set, to check against the business logic.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRbacPatternService = "rbac: pattern or service is not defined"
	ErrRbacClaim          = "rbac: claim is not set"
)

Error messages.

Functions

func NewLogger

func NewLogger(manager logger.Manager) *log

NewLogger creates a new logger.

func NewRbac

func NewRbac(r RoleService) *rbac

NewRbac creates a new rbac.

Types

type RoleService

type RoleService interface {
	// Allowed returns a boolean if the access is granted.
	// For the given url, HTTP method and jwt claim which includes specific user information.
	Allowed(pattern string, HTTPMethod string, claims interface{}) bool
}

RoleService interface

Directories

Path Synopsis
Package jwt provides a parser, generator and a middleware to checks if a jwt-token is valid.
Package jwt provides a parser, generator and a middleware to checks if a jwt-token is valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳