1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-27 17:05:36 +02:00

allow default-token and per-subscription tokens in client.yml

This commit is contained in:
Hunter Kehoe 2023-03-05 22:57:51 -07:00
parent 477c9d3ed5
commit 25be5b47e4
11 changed files with 572 additions and 65 deletions
server

View file

@ -1622,6 +1622,7 @@ func (s *Server) autorizeTopic(next handleFunc, perm user.Permission) handleFunc
// maybeAuthenticate reads the "Authorization" header and will try to authenticate the user
// if it is set.
//
// - If auth-db is not configured, immediately return an IP-based visitor
// - If the header is not set or not supported (anything non-Basic and non-Bearer),
// an IP-based visitor is returned
// - If the header is set, authenticate will be called to check the username/password (Basic auth),
@ -1633,13 +1634,14 @@ func (s *Server) maybeAuthenticate(r *http.Request) (*visitor, error) {
// Read "Authorization" header value, and exit out early if it's not set
ip := extractIPAddress(r, s.config.BehindProxy)
vip := s.visitor(ip, nil)
if s.userManager == nil {
return vip, nil
}
header, err := readAuthHeader(r)
if err != nil {
return vip, err
} else if !supportedAuthHeader(header) {
return vip, nil
} else if s.userManager == nil {
return vip, errHTTPUnauthorized
}
// If we're trying to auth, check the rate limiter first
if !vip.AuthAllowed() {