mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 02:17:25 +02:00
Mark secret values with log.WithSecrets on a separate line instead of nesting the call in argument lists. Also mark Last.fm/ListenBrainz session keys written through SessionKeys.Put and the PasswordEncryptionKey checksum, which still reached trace logs, and ignore values shorter than 8 characters so a short plaintext marked after a failed encryption cannot mangle SQL text or the [REDACTED] marker.
27 lines
733 B
Go
27 lines
733 B
Go
package agents
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/navidrome/navidrome/log"
|
|
"github.com/navidrome/navidrome/model"
|
|
)
|
|
|
|
// SessionKeys is a simple wrapper around the UserPropsRepository
|
|
type SessionKeys struct {
|
|
model.DataStore
|
|
KeyName string
|
|
}
|
|
|
|
func (sk *SessionKeys) Put(ctx context.Context, userId, sessionKey string) error {
|
|
ctx = log.WithSecrets(ctx, sessionKey)
|
|
return sk.DataStore.UserProps().Put(ctx, userId, sk.KeyName, sessionKey)
|
|
}
|
|
|
|
func (sk *SessionKeys) Get(ctx context.Context, userId string) (string, error) {
|
|
return sk.DataStore.UserProps().Get(ctx, userId, sk.KeyName)
|
|
}
|
|
|
|
func (sk *SessionKeys) Delete(ctx context.Context, userId string) error {
|
|
return sk.DataStore.UserProps().Delete(ctx, userId, sk.KeyName)
|
|
}
|