This commit is contained in:
ponzischeme89
2026-08-27 07:31:57 +12:00
parent 394a6d9b57
commit b0b8990f90
24 changed files with 388 additions and 477 deletions
+13 -1
View File
@@ -87,6 +87,13 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, "device name is too long")
return
}
log := s.loggerFor(r.Context()).With(
"emby_client", s.cfg.ClientName,
"device", req.DeviceName,
"device_id", req.DeviceID,
"client_version", clientVersion(r),
)
log.Info("Emby client registration starting")
auth, err := s.emby.Authenticate(
r.Context(), req.Username, req.Password,
@@ -98,7 +105,7 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
if err != nil {
// Never echo Emby's body here: a failed sign-in is the one place a wrong
// password could be reflected back.
s.loggerFor(r.Context()).Warn("sign-in rejected",
log.Warn("sign-in rejected",
"username", req.Username, "device", req.DeviceName, "device_id", req.DeviceID,
"reason", "emby refused the credentials",
)
@@ -179,6 +186,11 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
if len(created.ReplacedHash) > 0 {
_ = s.cache.Delete(r.Context(), cache.SessionKey(hexHash(created.ReplacedHash)))
}
log.Info("Emby client registration succeeded",
"user", sess.Username,
"user_id", sess.EmbyUserID,
"replaced", len(created.ReplacedHash) > 0,
)
s.retireSupersededDevices(r.Context(), created.Superseded)
// Recorded after the session exists, so a build history can only describe a
// television that got as far as signing in.