rbac

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PermissionInjectorMiddleware

func PermissionInjectorMiddleware(permission Permission) func(next http.Handler) http.Handler

PermissionInjectorMiddleware injects the permission into the context

func RBAC

func RBAC(roles []Role) func(next http.Handler) http.Handler

RBAC is a middleware that checks if the user has the required permission

Types

type Permission

type Permission struct {
	Scope  string
	Action string
}

func PermissionFromContext

func PermissionFromContext(ctx context.Context) (Permission, error)

type Role

type Role struct {
	Name        string
	Permissions []Permission
}

func FindRole

func FindRole(roles []Role, roleName string) *Role

func SetupRoles

func SetupRoles() []Role

func (*Role) HasPermission

func (r *Role) HasPermission(p Permission) bool

func (*Role) HasPermissions

func (r *Role) HasPermissions(perms []Permission) bool

Jump to

Keyboard shortcuts

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