Documentation ¶
Overview ¶
Package db contains methods to retrieve and modify local data.
Index ¶
- Variables
- func AddPolicy(p *db.Policy) (err error)
- func CreateRole(role db.Role) error
- func CreateUser(user *db.User) error
- func DeletePolicy(p *db.Policy) (err error)
- func DeleteRole(name string) error
- func DeleteUser(name string) error
- func GetPolicies() (result []*db.Policy, err error)
- func GetRole(name string) (db.Role, error)
- func GetRoles() ([]db.Role, error)
- func GetUser(name string) (*db.User, error)
- func GetUsers() ([]*db.User, error)
- func GetUsersByRole(role string) ([]*db.User, error)
- func RoleExists(name string) (bool, error)
- func UpdateUser(name string, update *db.User) error
- func UserExists(name string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var Enforcer *casbin.Enforcer
Enforcer is the casbin enforcer used for authorization.
var ErrAlreadyExists = errors.New("new entity already existed")
ErrAlreadyExists means that the new entity already existed.
var ErrNotFound = skv.ErrNotFound
ErrNotFound means that the requested entity was not found.
var ErrRoleHasPolicies = errors.New("there are policies associated with this role")
ErrRoleHasPolicies means that there are policies associated with this role.
var ErrRoleHasUsers = errors.New("there are users associated with this role")
ErrRoleHasUsers means that there are users associated with this role.
var ErrRoleNotFound = errors.New("associated role was not found")
ErrRoleNotFound means that the associated role was not found.
var ( // RoleDB is the KV-Store for roles. RoleDB *skv.KVStore )
var ( // UserDB is the KV-Store for users. UserDB *skv.KVStore )
Functions ¶
func CreateRole ¶
CreateRole creates the role. possible errors: ErrAlreadyExists.
func CreateUser ¶
CreateUser creates the user and hash and salts the password. possible errors: ErrAlreadyExists, ErrRoleNotFound.
func DeletePolicy ¶
DeletePolicy deletes the policy. possible errors: ErrNotFound.
func DeleteRole ¶
DeleteRole deletes the role. possible errors: ErrNotFound, ErrRoleHasUsers, ErrRoleHasPolicies.
func DeleteUser ¶
DeleteUser deletes the user. possible errors: ErrNotFound.
func GetPolicies ¶
GetPolicies returns all policies.
func GetUsersByRole ¶
GetUsersByRole returns all users associated with the role possible errors: ErrRoleNotFound
func UpdateUser ¶
UpdateUser updates the user. hash and salts the password if updated. possible errors: ErrNotFound, ErrRoleNotFound.
Types ¶
This section is empty.