permissions¶
import "github.com/Mini-Vending/go-services/packages/permissions"
Index¶
- Constants
- Variables
- func Interceptor(logger logger.Logger, manager *Manager, excludePaths []string) grpc.UnaryServerInterceptor
- type Config
- type Manager
- func NewManager(logger logger.Logger) (*Manager, error)
- func (m *Manager) GetMethodsByRole(role string) (map[string][]string, error)
- func (m *Manager) GetRequiredPermission(resource, method string) (string, bool)
- func (m *Manager) HasPermission(role, resource, method string) bool
- type ManagerInterface
- type Resource
- type Role
Constants¶
const (
RoleAdmin = "admin"
RoleMerchant = "merchant"
)
Variables¶
var (
ErrUnauthenticated = errors.New("unauthenticated")
ErrInsufficientPermissions = errors.New("insufficient permissions")
GrpcErrUnauthenticated = status.Error(codes.Unauthenticated, "unauthenticated")
GrpcErrInsufficientPermissions = status.Error(codes.PermissionDenied, "insufficient permissions")
GrpcErrRoleNotFound = status.Error(codes.NotFound, "role not found")
)
func Interceptor¶
func Interceptor(logger logger.Logger, manager *Manager, excludePaths []string) grpc.UnaryServerInterceptor
type Config¶
type Config struct {
Resources map[string]Resource `yaml:"resources"`
Roles map[string]Role `yaml:"roles"`
}
type Manager¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager¶
func NewManager(logger logger.Logger) (*Manager, error)
func (*Manager) GetMethodsByRole¶
func (m *Manager) GetMethodsByRole(role string) (map[string][]string, error)
func (*Manager) GetRequiredPermission¶
func (m *Manager) GetRequiredPermission(resource, method string) (string, bool)
func (*Manager) HasPermission¶
func (m *Manager) HasPermission(role, resource, method string) bool
type ManagerInterface¶
type ManagerInterface interface {
HasPermission(role, resource, method string) bool
GetRequiredPermission(resource, method string) (string, bool)
}
type Resource¶
type Resource struct {
Methods map[string]string `yaml:"methods"`
}
type Role¶
type Role struct {
Permissions map[string][]string `yaml:"permissions"`
}
common¶
import "github.com/Mini-Vending/go-services/packages/permissions/common"
Index¶
Variables¶
var PermissionsConfigYML []byte
Generated by gomarkdoc