fix(auth): a password reset signs out Subsonic apps too, and a change can (#8107)
A reset ended every session but left the API key and Subsonic password working, and anyone signed in to the account can make either. So whoever had the account kept it through a Subsonic app after the owner reset the password. The forgotten-password reset and an admin's reset now replace the API key with one nobody holds and clear the Subsonic password. A self-service change keeps Subsonic apps signed in by default, since it would sign out the owner's own apps too. The web and Android password forms gain "Sign out Subsonic apps too", sent as sign_out_subsonic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,11 @@ import (
|
||||
type changePasswordReq struct {
|
||||
CurrentPassword string `json:"current_password"`
|
||||
NewPassword string `json:"new_password"`
|
||||
// SignOutSubsonic also ends the account's Subsonic apps' access, for
|
||||
// someone changing a password they think another person knows. It is a
|
||||
// choice here, unlike on a reset, because it signs out the owner's own
|
||||
// apps too: they make a new key or Subsonic password in Settings.
|
||||
SignOutSubsonic bool `json:"sign_out_subsonic"`
|
||||
}
|
||||
|
||||
// handleChangePassword implements PUT /api/me/password. Self-service:
|
||||
@@ -74,7 +79,17 @@ func (h *handlers) handleChangePassword(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
}
|
||||
|
||||
audit.WriteOrLog(r.Context(), h.pool, h.logger, user.ID, user.ID, audit.ActionPasswordChangeSelf, nil)
|
||||
var auditMeta map[string]any
|
||||
if req.SignOutSubsonic {
|
||||
if err := h.signOutSubsonicApps(r.Context(), user.ID); err != nil {
|
||||
h.logger.Error("change password: sign out subsonic apps failed", "err", err)
|
||||
writeErr(w, apierror.Internal(err))
|
||||
return
|
||||
}
|
||||
auditMeta = map[string]any{"signed_out_subsonic": true}
|
||||
}
|
||||
|
||||
audit.WriteOrLog(r.Context(), h.pool, h.logger, user.ID, user.ID, audit.ActionPasswordChangeSelf, auditMeta)
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user