fix(subsonic): a handler without a caller answers error 50 everywhere (#8002)
Sixteen handlers answered a missing caller with error 50 "Not authenticated"; the star, unstar and scrobble handlers answered error 0 "Unauthenticated". Middleware stops such a request first, so no app saw it, but the next handler copied would pick one at random. requireUser now holds the check, the same shape as /api's, at all 21 sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,9 +63,8 @@ type UsersContainer struct {
|
||||
// getUsers lists every user, for an admin only; anyone else gets
|
||||
// ErrNotAuthorized, as the spec has it.
|
||||
func (h *userHandlers) getUsers(w http.ResponseWriter, r *http.Request) {
|
||||
caller, ok := UserFromContext(r.Context())
|
||||
caller, ok := requireUser(w, r)
|
||||
if !ok {
|
||||
WriteFail(w, r, ErrNotAuthorized, "Not authenticated")
|
||||
return
|
||||
}
|
||||
if !caller.IsAdmin {
|
||||
@@ -89,9 +88,8 @@ func (h *userHandlers) getUsers(w http.ResponseWriter, r *http.Request) {
|
||||
// unknown username is ErrDataNotFound. Per spec a non-admin asking about
|
||||
// another user gets ErrNotAuthorized.
|
||||
func (h *userHandlers) getUser(w http.ResponseWriter, r *http.Request) {
|
||||
caller, ok := UserFromContext(r.Context())
|
||||
caller, ok := requireUser(w, r)
|
||||
if !ok {
|
||||
WriteFail(w, r, ErrNotAuthorized, "Not authenticated")
|
||||
return
|
||||
}
|
||||
requested := r.URL.Query().Get("username")
|
||||
|
||||
Reference in New Issue
Block a user