authorization

package
v0.0.0-...-723301f Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationService

type AuthorizationService interface {
	Enforce(*token.Payload, string, string) (bool, error)
}

func NewCasbinAuthorization

func NewCasbinAuthorization(loader Loaders) (AuthorizationService, error)

type CasbinAuthorization

type CasbinAuthorization struct {
	Adapter  *pgadapter.Adapter
	Enforcer *casbin.Enforcer
}

func (*CasbinAuthorization) Enforce

func (authorize *CasbinAuthorization) Enforce(sub *token.Payload, obj string, act string) (bool, error)

type CasbinLogger

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

CasbinLogger is the implementation for a CasbinLogger using golang log.

func NewCasbinLogger

func NewCasbinLogger(enabled bool, logger *zap.Logger) *CasbinLogger

func (*CasbinLogger) EnableLog

func (l *CasbinLogger) EnableLog(enable bool)

func (*CasbinLogger) IsEnabled

func (l *CasbinLogger) IsEnabled() bool

func (*CasbinLogger) LogEnforce

func (l *CasbinLogger) LogEnforce(matcher string, request []interface{}, result bool, explains [][]string)

func (*CasbinLogger) LogError

func (l *CasbinLogger) LogError(err error, msg ...string)

func (*CasbinLogger) LogModel

func (l *CasbinLogger) LogModel(model [][]string)

func (*CasbinLogger) LogPolicy

func (l *CasbinLogger) LogPolicy(policy map[string][][]string)

func (*CasbinLogger) LogRole

func (l *CasbinLogger) LogRole(roles []string)

type CasbinManagement

type CasbinManagement struct {
	Adapter  *pgadapter.Adapter
	Enforcer *casbin.Enforcer
}

func (*CasbinManagement) AddPolicies

func (management *CasbinManagement) AddPolicies(resource string, username string, rights string) error

func (*CasbinManagement) CreateAdminPolicies

func (management *CasbinManagement) CreateAdminPolicies(adminName string, companyId int64) error

func (*CasbinManagement) CreateCompanyPolicies

func (management *CasbinManagement) CreateCompanyPolicies(companyId int64, user string) error

func (*CasbinManagement) CreateProjectPolicies

func (management *CasbinManagement) CreateProjectPolicies(projectId int64, client string, responsible string, companyId int64) error

func (*CasbinManagement) CreateSuperAdminPolicies

func (management *CasbinManagement) CreateSuperAdminPolicies(superAdminName string) error

func (*CasbinManagement) CreateTaskPolicies

func (management *CasbinManagement) CreateTaskPolicies(taskId int64, projectId int64, author string, companyId int64) error

func (*CasbinManagement) CreateUserPolicies

func (management *CasbinManagement) CreateUserPolicies(username string, role string, companyId int64) error

func (*CasbinManagement) RemoveCompanyPolicies

func (management *CasbinManagement) RemoveCompanyPolicies(companyId int64, user string) error

func (*CasbinManagement) RemovePolicies

func (management *CasbinManagement) RemovePolicies(resource string, username string) error

func (*CasbinManagement) RemoveProjectPolicies

func (management *CasbinManagement) RemoveProjectPolicies(projectId int64, client string, responsible string, companyId int64) error

func (*CasbinManagement) RemoveTaskPolicies

func (management *CasbinManagement) RemoveTaskPolicies(taskId int64, projectId int64, author string, companyId int64) error

func (*CasbinManagement) RemoveUserPolicies

func (management *CasbinManagement) RemoveUserPolicies(username string) error

type FakeLoader

type FakeLoader struct {
	Adapter  *fileadapter.Adapter
	Enforcer *casbin.Enforcer
}

type Loaders

type Loaders struct {
	Adapter  *pgadapter.Adapter
	Enforcer *casbin.Enforcer
}

func Load

func Load(source string, conf string) (*Loaders, error)

type PolicyManagementService

type PolicyManagementService interface {
	RemoveUserPolicies(string) error
	RemoveProjectPolicies(int64, string, string, int64) error
	CreateSuperAdminPolicies(string) error
	CreateAdminPolicies(string, int64) error
	CreateUserPolicies(string, string, int64) error
	CreateProjectPolicies(int64, string, string, int64) error
	CreateTaskPolicies(int64, int64, string, int64) error
	RemoveTaskPolicies(int64, int64, string, int64) error
	CreateCompanyPolicies(int64, string) error
	RemoveCompanyPolicies(int64, string) error
}

func NewCasbinManagement

func NewCasbinManagement(loader Loaders) (PolicyManagementService, error)

Jump to

Keyboard shortcuts

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