permissions_models

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BackendForDB = backend.BackendForDB
View Source
var Register = backend.RegisterForDriver

Functions

func FilterGroupPermissions

func FilterGroupPermissions(rows []*UserGroupsRow) (Group, []*Permission)

Types

type DeleteQuerier

type DeleteQuerier interface {
	DeleteGroup(ctx context.Context, id uint64) error
	DeleteGroupPermission(ctx context.Context, groupID uint64, permissionID uint64) error
	DeletePermission(ctx context.Context, id uint64) error
	DeleteUserGroup(ctx context.Context, userID uint64, groupID uint64) error
}

type Group

type Group struct {
	ID          uint64 `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type GroupPermission

type GroupPermission struct {
	ID           uint64 `json:"id"`
	GroupID      uint64 `json:"group_id"`
	PermissionID uint64 `json:"permission_id"`
}

type InsertQuerier

type InsertQuerier interface {
	InsertGroup(ctx context.Context, name string, description string) (int64, error)
	InsertGroupPermission(ctx context.Context, groupID uint64, permissionID uint64) (int64, error)
	InsertPermission(ctx context.Context, name string, description string) (int64, error)
	InsertUserGroup(ctx context.Context, userID uint64, groupID uint64) (int64, error)
}

type Permission

type Permission struct {
	ID          uint64 `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Querier

type Querier interface {
	InsertQuerier
	DeleteQuerier
	UpdateQuerier

	WithTx(*sql.Tx) Querier
	Close() error

	AllGroups(ctx context.Context, limit int32, offset int32) ([]*Group, error)
	AllPermissions(ctx context.Context, limit int32, offset int32) ([]*Permission, error)
	GetGroupByID(ctx context.Context, id uint64) (*Group, error)
	GetPermissionByID(ctx context.Context, id uint64) (*Permission, error)
	PermissionsForUser(ctx context.Context, userID uint64) ([]*Permission, error)
	UserGroups(ctx context.Context, id uint64) (g Group, p []*Permission, err error)
	UserHasPermission(ctx context.Context, userID uint64, permissionName string) (int64, error)
}

type UpdateQuerier

type UpdateQuerier interface {
	UpdateGroup(ctx context.Context, name string, description string, iD uint64) error
	UpdatePermission(ctx context.Context, name string, description string, iD uint64) error
}

type UserGroup

type UserGroup struct {
	ID      uint64 `json:"id"`
	UserID  uint64 `json:"user_id"`
	GroupID uint64 `json:"group_id"`
}

type UserGroupsRow

type UserGroupsRow struct {
	Group      Group      `json:"group"`
	Permission Permission `json:"permission"`
}

Jump to

Keyboard shortcuts

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