acl

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermView      = `view`
	PermCreate    = `create`
	PermUpdate    = `update`
	PermDelete    = `delete`
	PermList      = `list`
	PermAuthCross = session.PermAuthCross
	PermCount     = `count`
	PermApprove   = `approve`
	PermReject    = `reject`
	PermGet       = `get`
	PermSet       = `set`
)

The permission list

Variables

View Source
var ErrNoPermissions = &ACLError{Message: "no permissions"}

Functions

func HasPermission

func HasPermission(ctx context.Context, permissions ...string) bool

HasPermission returns `true` if the `user` have all permissions from the list (without custom check)

func HaveAccessCount

func HaveAccessCount(ctx context.Context, obj any) bool

HaveAccessCount of the object returns `true` if user can count the object

func HaveAccessCreate

func HaveAccessCreate(ctx context.Context, obj any) bool

HaveAccessCreate of the object returns `true` if user can create this type of object

func HaveAccessDelete

func HaveAccessDelete(ctx context.Context, obj any) bool

HaveAccessDelete of the object returns `true` if user can delite the object

func HaveAccessList

func HaveAccessList(ctx context.Context, obj any) bool

HaveAccessList to the object returns `true` if user can read list of the object

func HaveAccessUpdate

func HaveAccessUpdate(ctx context.Context, obj any) bool

HaveAccessUpdate of the object returns `true` if user can update the object

func HaveAccessView

func HaveAccessView(ctx context.Context, obj any) bool

HaveAccessView to the object returns `true` if user can read of the object

func HaveAccountLink(ctx context.Context, obj any) bool

HaveAccountLink of the object to the current account

func HaveObjectPermissions

func HaveObjectPermissions(ctx context.Context, obj any, permissions ...string) bool

HaveObjectPermissions returns `true` if the `user` have all permissions from the list for the object

func HavePermissions

func HavePermissions(ctx context.Context, permissions ...string) bool

HavePermissions returns `true` if the `user` have all permissions from the list

func InitModelPermissions

func InitModelPermissions(pm *permissions.Manager, models ...any)

InitModelPermissions for particular models

func InitModelPermissionsWithCustomCheck

func InitModelPermissionsWithCustomCheck(pm *permissions.Manager, customCheck checkFnk, models ...any)

InitModelPermissionsWithCustomCheck for particular models and extra custom check function

func IsNoPermCheck

func IsNoPermCheck(ctx context.Context) bool

IsNoPermCheck returns `true` if the permission check is disabled

func WithNoPermCheck

func WithNoPermCheck(ctx context.Context) context.Context

WithNoPermCheck returns new context with disabled permission check

Types

type ACLError

type ACLError struct {
	Message string
	// contains filtered or unexported fields
}

func (*ACLError) Error

func (err *ACLError) Error() string

func (*ACLError) Unwrap

func (err *ACLError) Unwrap() error

func (*ACLError) WithMessage

func (err *ACLError) WithMessage(message string) *ACLError

type RBACType

type RBACType struct {
	AccountID    uint64
	UserID       uint64
	ResourceName string
}

func (*RBACType) RBACResourceName

func (tp *RBACType) RBACResourceName() string

RBACResourceName returns the name of the resource for the RBAC

func (*RBACType) WithAccountID

func (tp *RBACType) WithAccountID(accountID uint64) RBACType

RBACAccountID returns the account ID for the RBAC

func (*RBACType) WithUserAccountID

func (tp *RBACType) WithUserAccountID(userID, accountID uint64) RBACType

RBACWithUserAccountID returns the user ID and account ID for the RBAC

func (*RBACType) WithUserID

func (tp *RBACType) WithUserID(userID uint64) RBACType

RBACUserID returns the user ID for the RBAC

Jump to

Keyboard shortcuts

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