1
0
Fork 0
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:
Philipp Heckel 2022-01-27 12:49:05 -05:00
parent e61a0c2f78
commit 631ade5430
2 changed files with 30 additions and 5 deletions
server

View file

@ -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)
}