casbin

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MiddlewareBuilder

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

MiddlewareBuilder is a struct that assembles middleware components by using the Casbin library for authorization and a file system watcher for policy changes.

func InitMiddlewareBuilder added in v0.0.20

func InitMiddlewareBuilder(modelFile, policyFile string, subResolver SubResolver) (*MiddlewareBuilder, error)

InitMiddlewareBuilder is a constructor function for MiddlewareBuilder. It initializes the Casbin enforcer, file system watcher, and sets up the policy file watching. It returns a pointer to the created MiddlewareBuilder and any error encountered during the initialization process.

func (*MiddlewareBuilder) Build

func (b *MiddlewareBuilder) Build() mist.Middleware

Build is a method that constructs the middleware used to check permissions on each request.

func (*MiddlewareBuilder) Close

func (b *MiddlewareBuilder) Close() error

Close is a cleanup function to close the file watcher when the MiddlewareBuilder is no longer needed.

func (*MiddlewareBuilder) UpdatePolicy

func (b *MiddlewareBuilder) UpdatePolicy() error

UpdatePolicy is a method that reloads the enforcement policy from the policy file.

type SubResolver

type SubResolver func(*http.Request) (string, error)

SubResolver Define a type for a function that resolves a subject (user) from an HTTP request. This function must return the resolved subject as a string and any potential error encountered during the process.

Jump to

Keyboard shortcuts

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