casbin

package module
v0.0.0-...-d86cf4f Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 2 Imported by: 0

README

casbin

Casbin Middleware for Gofiber

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{}

DefaultConfig is the default config

Functions

func New

func New(cfg Config) fiber.Handler

New creates a new middleware for Casbin middleware

Types

type Config

type Config struct {
	Enforcer *casbin.Enforcer

	// Authorizer defines a function you can pass
	// to check the credentials however you want.
	// It will be called with a username and password
	// and is expected to return true or false to indicate
	// that the credentials were approved or not.
	//
	// Optional. Default: nil.
	Authorizer func(sub, obj, action string) bool

	// Unauthorized defines the response body for unauthorized responses.
	// By default it will return with a 401 Unauthorized and the correct WWW-Auth header
	//
	// Optional. Default: nil
	Unauthorized fiber.Handler
}

Config is the configuration for Casbin middleware

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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