Documentation ¶
Index ¶
- Constants
- Variables
- func HasPermission(ctx context.Context, permissions ...string) bool
- func HaveAccessCount(ctx context.Context, obj any) bool
- func HaveAccessCreate(ctx context.Context, obj any) bool
- func HaveAccessDelete(ctx context.Context, obj any) bool
- func HaveAccessList(ctx context.Context, obj any) bool
- func HaveAccessUpdate(ctx context.Context, obj any) bool
- func HaveAccessView(ctx context.Context, obj any) bool
- func HaveAccountLink(ctx context.Context, obj any) bool
- func HaveObjectPermissions(ctx context.Context, obj any, permissions ...string) bool
- func HavePermissions(ctx context.Context, permissions ...string) bool
- func InitModelPermissions(pm *permissions.Manager, models ...any)
- func InitModelPermissionsWithCustomCheck(pm *permissions.Manager, customCheck checkFnk, models ...any)
- func IsNoPermCheck(ctx context.Context) bool
- func WithNoPermCheck(ctx context.Context) context.Context
- type ACLError
- type RBACType
Constants ¶
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 ¶
var ErrNoPermissions = &ACLError{Message: "no permissions"}
Functions ¶
func HasPermission ¶
HasPermission returns `true` if the `user` have all permissions from the list (without custom check)
func HaveAccessCount ¶
HaveAccessCount of the object returns `true` if user can count the object
func HaveAccessCreate ¶
HaveAccessCreate of the object returns `true` if user can create this type of object
func HaveAccessDelete ¶
HaveAccessDelete of the object returns `true` if user can delite the object
func HaveAccessList ¶
HaveAccessList to the object returns `true` if user can read list of the object
func HaveAccessUpdate ¶
HaveAccessUpdate of the object returns `true` if user can update the object
func HaveAccessView ¶
HaveAccessView to the object returns `true` if user can read of the object
func HaveAccountLink ¶
HaveAccountLink of the object to the current account
func HaveObjectPermissions ¶
HaveObjectPermissions returns `true` if the `user` have all permissions from the list for the object
func HavePermissions ¶
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 ¶
IsNoPermCheck returns `true` if the permission check is disabled
Types ¶
type ACLError ¶
type ACLError struct { Message string // contains filtered or unexported fields }
func (*ACLError) WithMessage ¶
type RBACType ¶
func (*RBACType) RBACResourceName ¶
RBACResourceName returns the name of the resource for the RBAC
func (*RBACType) WithAccountID ¶
RBACAccountID returns the account ID for the RBAC
func (*RBACType) WithUserAccountID ¶
RBACWithUserAccountID returns the user ID and account ID for the RBAC
func (*RBACType) WithUserID ¶
RBACUserID returns the user ID for the RBAC