policy

package
v0.0.0-...-dd01cb3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionPolicyUpdate = "policy:update"
	ActionPolicyRead   = "policy:read"
	Object             = "policy"
)

Variables

This section is empty.

Functions

func NewMongoDBCasbinEnforcer

func NewMongoDBCasbinEnforcer(conf CasbinConfig) *casbin.Enforcer

Types

type CasbinConfig

type CasbinConfig struct {
	MongoDB    mongodb.Config
	CongifPath string `envconfig:"CONFIG_PATH" default:"configs/casbin.conf"`
}

type Handler

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

func NewHandler

func NewHandler(svc service) *Handler

func (*Handler) Routes

func (h *Handler) Routes() []router.Route

type Service

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

func New

func New(enforcer *casbin.Enforcer) (*Service, error)

New return a new instance of policy service

func (*Service) AddPolicy

func (s *Service) AddPolicy(ctx context.Context, req types.Policy) error

func (*Service) GetAllMods

func (s *Service) GetAllMods(ctx context.Context, id string) ([]string, error)

GetAllMods get all moderators of one community

func (*Service) IsAllowed

func (s *Service) IsAllowed(ctx context.Context, sub string, obj string, act string) bool

IsAllowed check if the sub is allowed to do the action on that object.

func (*Service) RemovePolicy

func (s *Service) RemovePolicy(ctx context.Context, idOwner, idCom string) error

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, obj string, act string) error

Validate validate if the current user is allowed to do the action on the object.

Jump to

Keyboard shortcuts

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