mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-15 17:13:24 +02:00
Support multiple topics in auth
This commit is contained in:
parent
e61a0c2f78
commit
631ade5430
2 changed files with 30 additions and 5 deletions
server
|
@ -1140,7 +1140,7 @@ func (s *Server) withAuth(next handleFunc, perm auth.Permission) handleFunc {
|
|||
if s.auth == nil {
|
||||
return next(w, r, v)
|
||||
}
|
||||
t, err := s.topicFromPath(r.URL.Path)
|
||||
topics, _, err := s.topicsFromPath(r.URL.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1152,9 +1152,11 @@ func (s *Server) withAuth(next handleFunc, perm auth.Permission) handleFunc {
|
|||
return errHTTPUnauthorized
|
||||
}
|
||||
}
|
||||
if err := s.auth.Authorize(user, t.ID, perm); err != nil {
|
||||
log.Printf("unauthorized: %s", err.Error())
|
||||
return errHTTPForbidden
|
||||
for _, t := range topics {
|
||||
if err := s.auth.Authorize(user, t.ID, perm); err != nil {
|
||||
log.Printf("unauthorized: %s", err.Error())
|
||||
return errHTTPForbidden
|
||||
}
|
||||
}
|
||||
return next(w, r, v)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue