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:
2026-11-26 12:44:05 -05:00
co-authored by Claude Opus 5.5
parent 0811775af6
commit cfdd6b916f
10 changed files with 32 additions and 42 deletions
+4 -8
View File
@@ -18,9 +18,8 @@ import (
// albumId, artistId. All entities are validated before any insert; a single
// missing entity fails the whole call with Subsonic error 70.
func (m *mediaHandlers) handleStar(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrGeneric, "Unauthenticated")
return
}
params := r.URL.Query()
@@ -70,9 +69,8 @@ func (m *mediaHandlers) handleStar(w http.ResponseWriter, r *http.Request) {
// as a no-op rather than an error — Subsonic clients commonly call unstar
// on entities the server has never seen (cross-server library moves).
func (m *mediaHandlers) handleUnstar(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrGeneric, "Unauthenticated")
return
}
params := r.URL.Query()
@@ -137,9 +135,8 @@ func resolveStarID(ctx context.Context, q *dbq.Queries, raw string, kind entityK
}
func (m *mediaHandlers) handleGetStarred(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrGeneric, "Unauthenticated")
return
}
q := dbq.New(m.pool)
@@ -159,9 +156,8 @@ func (m *mediaHandlers) handleGetStarred(w http.ResponseWriter, r *http.Request)
}
func (m *mediaHandlers) handleGetStarred2(w http.ResponseWriter, r *http.Request) {
user, ok := UserFromContext(r.Context())
user, ok := requireUser(w, r)
if !ok {
WriteFail(w, r, ErrGeneric, "Unauthenticated")
return
}
q := dbq.New(m.pool)