Documentation
¶
Overview ¶
Package auth responsible for authentification and authorization of users
Index ¶
- Constants
- func GetRolePermissions() map[string][]typesv2.Permission
- func IsEcludedFromAuth(service, method string) bool
- func IsEcludedFromRBAC(service, method string) bool
- func SetEnforcer(e *Enforcer)
- type Enforcer
- func (e *Enforcer) AddPolicy(sub, obj, act string) error
- func (e *Enforcer) AddResourceForUser(user, resource string) error
- func (e *Enforcer) AddRoleForUser(user, role string) error
- func (e *Enforcer) CheckPermission(roles []string, obj, act string) bool
- func (e *Enforcer) GetResourcesForUser(user string) ([]string, error)
- func (e *Enforcer) GetRolesForUser(user string) ([]string, error)
- func (e *Enforcer) GetUsersForRole(role string) ([]string, error)
- func (e *Enforcer) RemovePolicy(sub, obj, act string) error
- func (e *Enforcer) SetUpdateChannel(ch chan database.RoleSubscriptionEvent)
- func (e *Enforcer) Shutdown()
- type MemoryAdapter
- func (a *MemoryAdapter) AddPolicy(sec string, ptype string, rule []string) error
- func (a *MemoryAdapter) LoadPolicy(m model.Model) error
- func (a *MemoryAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *MemoryAdapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *MemoryAdapter) SavePolicy(m model.Model) error
Constants ¶
const ( // ApplicationService service constants ApplicationService = "ApplicationService" ApplicationServiceCreate = "Create" ApplicationServiceCreateTask = "CreateTask" ApplicationServiceCreateTaskAll = "CreateTaskAll" ApplicationServiceDeallocate = "Deallocate" ApplicationServiceDeallocateAll = "DeallocateAll" ApplicationServiceGet = "Get" ApplicationServiceGetAll = "GetAll" ApplicationServiceGetResource = "GetResource" ApplicationServiceGetResourceAll = "GetResourceAll" ApplicationServiceGetState = "GetState" ApplicationServiceGetStateAll = "GetStateAll" ApplicationServiceGetTask = "GetTask" ApplicationServiceGetTaskAll = "GetTaskAll" ApplicationServiceList = "List" ApplicationServiceListAll = "ListAll" ApplicationServiceListResource = "ListResource" ApplicationServiceListResourceAll = "ListResourceAll" ApplicationServiceListState = "ListState" ApplicationServiceListStateAll = "ListStateAll" ApplicationServiceListTask = "ListTask" ApplicationServiceListTaskAll = "ListTaskAll" // AuthService service constants AuthService = "AuthService" AuthServiceLogin = "Login" AuthServiceValidateToken = "ValidateToken" AuthServiceGetPermissions = "GetPermissions" AuthServiceRefreshToken = "RefreshToken" // GateProxySSHService service constants GateProxySSHService = "GateProxySSHService" GateProxySSHServiceGetResourceAccess = "GetResourceAccess" GateProxySSHServiceGetResourceAccessAll = "GetResourceAccessAll" // LabelService service constants LabelService = "LabelService" LabelServiceCreate = "Create" LabelServiceCreateAll = "CreateAll" LabelServiceGet = "Get" LabelServiceGetAll = "GetAll" LabelServiceList = "List" LabelServiceListAll = "ListAll" LabelServiceRemove = "Remove" LabelServiceRemoveAll = "RemoveAll" LabelServiceUpdate = "Update" LabelServiceUpdateAll = "UpdateAll" // NodeService service constants NodeService = "NodeService" NodeServiceGet = "Get" NodeServiceGetThis = "GetThis" NodeServiceList = "List" NodeServiceSetMaintenance = "SetMaintenance" // RoleService service constants RoleService = "RoleService" RoleServiceCreate = "Create" RoleServiceGet = "Get" RoleServiceList = "List" RoleServiceRemove = "Remove" RoleServiceUpdate = "Update" // StreamingService service constants StreamingService = "StreamingService" StreamingServiceConnect = "Connect" StreamingServiceSubscribe = "Subscribe" // UserService service constants UserService = "UserService" UserServiceGetMe = "GetMe" UserServiceCreate = "Create" UserServiceCreateGroup = "CreateGroup" UserServiceGet = "Get" UserServiceGetGroup = "GetGroup" UserServiceList = "List" UserServiceListGroup = "ListGroup" UserServiceRemove = "Remove" UserServiceRemoveGroup = "RemoveGroup" UserServiceUpdate = "Update" UserServiceUpdateAll = "UpdateAll" UserServiceUpdateGroup = "UpdateGroup" UserServiceUpdatePassword = "UpdatePassword" UserServiceUpdateRoles = "UpdateRoles" )
Service and Method constants
const (
AdminRoleName = "Administrator"
)
Variables ¶
This section is empty.
Functions ¶
func GetRolePermissions ¶
func GetRolePermissions() map[string][]typesv2.Permission
GetRolePermissions returns a map of all possible permissions for all known roles
func IsEcludedFromAuth ¶
IsEcludedFromAuth helps connectrpc to exclude methods from Auth validation
func IsEcludedFromRBAC ¶
IsEcludedFromRBAC helps connectrpc to exclude methods from RBAC validation
Types ¶
type Enforcer ¶
type Enforcer struct {
// contains filtered or unexported fields
}
Enforcer wraps Casbin enforcer with additional functionality
func NewEnforcer ¶
NewEnforcer creates a new Casbin enforcer with the embedded model and memory adapter
func (*Enforcer) AddResourceForUser ¶
AddResourceForUser adds a resource ownership for a user
func (*Enforcer) AddRoleForUser ¶
AddRoleForUser adds a role for a user
func (*Enforcer) CheckPermission ¶
CheckPermission checks if the roles has permission to perform the action on the object
func (*Enforcer) GetResourcesForUser ¶
GetResourcesForUser gets resources owned by a user
func (*Enforcer) GetRolesForUser ¶
GetRolesForUser gets roles for a user
func (*Enforcer) GetUsersForRole ¶
GetUsersForRole gets users that have a role
func (*Enforcer) RemovePolicy ¶
RemovePolicy removes a policy rule
func (*Enforcer) SetUpdateChannel ¶
func (e *Enforcer) SetUpdateChannel(ch chan database.RoleSubscriptionEvent)
type MemoryAdapter ¶
type MemoryAdapter struct {
// contains filtered or unexported fields
}
MemoryAdapter implements Casbin's persist.Adapter interface using in-memory storage
func NewMemoryAdapter ¶
func NewMemoryAdapter() *MemoryAdapter
NewMemoryAdapter creates a new adapter instance
func (*MemoryAdapter) AddPolicy ¶
func (a *MemoryAdapter) AddPolicy(sec string, ptype string, rule []string) error
AddPolicy adds a policy rule to memory
func (*MemoryAdapter) LoadPolicy ¶
func (a *MemoryAdapter) LoadPolicy(m model.Model) error
LoadPolicy loads policy rules from memory
func (*MemoryAdapter) RemoveFilteredPolicy ¶
func (a *MemoryAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy removes policy rules that match the filter from memory
func (*MemoryAdapter) RemovePolicy ¶
func (a *MemoryAdapter) RemovePolicy(sec string, ptype string, rule []string) error
RemovePolicy removes a policy rule from memory
func (*MemoryAdapter) SavePolicy ¶
func (a *MemoryAdapter) SavePolicy(m model.Model) error
SavePolicy saves policy rules to memory