mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-14 16:43:37 +02:00
More auth
This commit is contained in:
parent
393f95aeac
commit
460162737a
9 changed files with 264 additions and 230 deletions
auth
20
auth/auth.go
20
auth/auth.go
|
@ -15,6 +15,7 @@ type Manager interface {
|
|||
User(username string) (*User, error)
|
||||
ChangePassword(username, password string) error
|
||||
ChangeRole(username string, role Role) error
|
||||
DefaultAccess() (read bool, write bool)
|
||||
AllowAccess(username string, topic string, read bool, write bool) error
|
||||
ResetAccess(username string, topic string) error
|
||||
}
|
||||
|
@ -42,21 +43,14 @@ const (
|
|||
type Role string
|
||||
|
||||
const (
|
||||
RoleAdmin = Role("admin")
|
||||
RoleUser = Role("user")
|
||||
RoleNone = Role("none")
|
||||
RoleAdmin = Role("admin")
|
||||
RoleUser = Role("user")
|
||||
RoleAnonymous = Role("anonymous")
|
||||
)
|
||||
|
||||
var Everyone = &User{
|
||||
Name: "",
|
||||
Role: RoleNone,
|
||||
}
|
||||
|
||||
var Roles = []Role{
|
||||
RoleAdmin,
|
||||
RoleUser,
|
||||
RoleNone,
|
||||
}
|
||||
const (
|
||||
Everyone = "*"
|
||||
)
|
||||
|
||||
func AllowedRole(role Role) bool {
|
||||
return role == RoleUser || role == RoleAdmin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue