More CLI for access control
This commit is contained in:
13
auth/auth.go
13
auth/auth.go
@@ -12,6 +12,9 @@ type Manager interface {
|
||||
AddUser(username, password string, role Role) error
|
||||
RemoveUser(username string) error
|
||||
ChangePassword(username, password string) error
|
||||
ChangeRole(username string, role Role) error
|
||||
AllowAccess(username string, topic string, read bool, write bool) error
|
||||
ResetAccess(username string, topic string) error
|
||||
}
|
||||
|
||||
type User struct {
|
||||
@@ -39,4 +42,14 @@ var Everyone = &User{
|
||||
Role: RoleNone,
|
||||
}
|
||||
|
||||
var Roles = []Role{
|
||||
RoleAdmin,
|
||||
RoleUser,
|
||||
RoleNone,
|
||||
}
|
||||
|
||||
func AllowedRole(role Role) bool {
|
||||
return role == RoleUser || role == RoleAdmin
|
||||
}
|
||||
|
||||
var ErrUnauthorized = errors.New("unauthorized")
|
||||
|
||||
Reference in New Issue
Block a user