Documentation ¶
Index ¶
- Constants
- func ArrayEquals(a []string, b []string) bool
- func ArrayRemoveDuplicates(s *[]string)
- func EscapeAssertion(s string) string
- func LogPrint(v ...interface{})
- func RemoveComments(s string) string
- type Assertion
- type Role
- type RoleManager
- func (m *RoleManager) AddRole(role *Role) (bool, error)
- func (m *RoleManager) AddRoleForUser(role string, user string) error
- func (m *RoleManager) AddRoleForUsers(role string, users []string) error
- func (m *RoleManager) AddRoles(roles []*Role) (bool, error)
- func (m *RoleManager) AddRolesForUser(user string, roles []string) error
- func (m *RoleManager) AssignRole(roleGroup string, role string) error
- func (m *RoleManager) AssignRoles(roleGroup string, roles []string) error
- func (m *RoleManager) CancelAssignRole(roleGroup string, role string) error
- func (m *RoleManager) CancelAssignRoles(roleGroup string, roles []string) error
- func (m *RoleManager) Close()
- func (m *RoleManager) CountRoles(likeRole ...string) (int64, error)
- func (m *RoleManager) GetRole(roleName string) (*Role, error)
- func (m *RoleManager) GetRoles(limit, offset int64, likeRole ...string) ([]*Role, int64, error)
- func (m *RoleManager) GetRolesForUser(name string, likeRoles ...string) ([]*Role, error)
- func (m *RoleManager) GetRolesHierarchyForUser(name string, likeRoles ...string) ([]*Role, error)
- func (m *RoleManager) GetUsersForRole(role string) ([]string, error)
- func (m *RoleManager) GetUsersForRoleHierarchy(role string) ([]*User, error)
- func (m *RoleManager) HasRole(roleName string) (bool, error)
- func (m *RoleManager) HasRoleForUser(role, user string) (bool, error)
- func (m *RoleManager) Load() error
- func (m *RoleManager) RemoveRole(name string) error
- func (m *RoleManager) RemoveRoleForUser(role, user string) error
- type Rule
- type User
- type UserType
- type XODB
Constants ¶
const ( // user for role relation UserForRoleRelation = "U" // role for role relation RoleForRoleRelation = "R" )
Variables ¶
This section is empty.
Functions ¶
func ArrayEquals ¶
ArrayEquals determines whether two string arrays are identical.
func ArrayRemoveDuplicates ¶
func ArrayRemoveDuplicates(s *[]string)
ArrayRemoveDuplicates removes any duplicated elements in a string array.
func EscapeAssertion ¶
EscapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.
func RemoveComments ¶
RemoveComments removes the comments starting with # in the text.
Types ¶
type Assertion ¶
Assertion represents an expression in a section of the model. For example: r = sub, obj, act
type RoleManager ¶
type RoleManager struct {
// contains filtered or unexported fields
}
RoleManager manage the user's role and role hierarchy.
func NewRoleManager ¶
func NewRoleManager(params ...interface{}) (*RoleManager, error)
NewRoleManager returns a new role manager
func (*RoleManager) AddRole ¶
func (m *RoleManager) AddRole(role *Role) (bool, error)
AddRole adds a role inside a rule. Returns false if the user already has the role (aka not affected).
func (*RoleManager) AddRoleForUser ¶
func (m *RoleManager) AddRoleForUser(role string, user string) error
AddRoleForUser adds a role to a user.
func (*RoleManager) AddRoleForUsers ¶
func (m *RoleManager) AddRoleForUsers(role string, users []string) error
AddRoleForUsers adds the same role to multiple users
func (*RoleManager) AddRoles ¶
func (m *RoleManager) AddRoles(roles []*Role) (bool, error)
AddRoles adds multiple roles inside the rule. Returns false if the user already has the role (aka not affected).
func (*RoleManager) AddRolesForUser ¶
func (m *RoleManager) AddRolesForUser(user string, roles []string) error
AddRolesForUser adds the multiple roles to a user
func (*RoleManager) AssignRole ¶
func (m *RoleManager) AssignRole(roleGroup string, role string) error
AssignRole assign a role to role group, the role includes all permissions for role group.
func (*RoleManager) AssignRoles ¶
func (m *RoleManager) AssignRoles(roleGroup string, roles []string) error
AssignRoles assign multiple roles to role group, the role includes all permissions for role group.
func (*RoleManager) CancelAssignRole ¶
func (m *RoleManager) CancelAssignRole(roleGroup string, role string) error
CancelAssignRole cancel assign a role to role group.
func (*RoleManager) CancelAssignRoles ¶
func (m *RoleManager) CancelAssignRoles(roleGroup string, roles []string) error
CancelAssignRoles cancel assign multiple role to role group.
func (*RoleManager) CountRoles ¶
func (m *RoleManager) CountRoles(likeRole ...string) (int64, error)
CountRoles gets the count of roles that show up in the current role.
func (*RoleManager) GetRole ¶
func (m *RoleManager) GetRole(roleName string) (*Role, error)
GetRole gets a role inside the rule.
func (*RoleManager) GetRolesForUser ¶
func (m *RoleManager) GetRolesForUser(name string, likeRoles ...string) ([]*Role, error)
GetRolesForUser gets the roles that a user has.
func (*RoleManager) GetRolesHierarchyForUser ¶
func (m *RoleManager) GetRolesHierarchyForUser(name string, likeRoles ...string) ([]*Role, error)
GetRolesHierarchyForUser gets all roles of hierarchy that a user has.
func (*RoleManager) GetUsersForRole ¶
func (m *RoleManager) GetUsersForRole(role string) ([]string, error)
GetUsersForRole gets the users that has a role inside the rule.
func (*RoleManager) GetUsersForRoleHierarchy ¶
func (m *RoleManager) GetUsersForRoleHierarchy(role string) ([]*User, error)
GetUsersForRoleHierarchy gets the users that has all role hierarchy inside the rule.
func (*RoleManager) HasRole ¶
func (m *RoleManager) HasRole(roleName string) (bool, error)
HasRole determines whether a role inside the rule.
func (*RoleManager) HasRoleForUser ¶
func (m *RoleManager) HasRoleForUser(role, user string) (bool, error)
HasRoleForUser determines whether a user has a role.
func (*RoleManager) RemoveRole ¶
func (m *RoleManager) RemoveRole(name string) error
RemoveRole deletes the role and all its users.
func (*RoleManager) RemoveRoleForUser ¶
func (m *RoleManager) RemoveRoleForUser(role, user string) error
RemoveRoleForUser deletes a role for the user.
type Rule ¶
type Rule struct { ID int64 PType string V0 string V1 string V2 string V3 string V4 string V5 string }
Rule the storage structure of the rule
type XODB ¶
type XODB interface { Exec(string, ...interface{}) (sql.Result, error) Query(string, ...interface{}) (*sql.Rows, error) QueryRow(string, ...interface{}) *sql.Row ExecContext(context.Context, string, ...interface{}) (sql.Result, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row DriverName() string Rebind(query string) string }
XODB This should work with database/sql.DB and database/sql.Tx.