feat: add subsonic token auth and starred endpoints

This commit is contained in:
2026-04-02 23:14:10 +03:00
parent a640251e7d
commit b16f9de6c8
10 changed files with 535 additions and 68 deletions

View File

@@ -11,6 +11,7 @@ import (
"golang.org/x/crypto/bcrypt"
"github.com/benya/temporserv/internal/auth"
"github.com/benya/temporserv/internal/config"
)
@@ -60,16 +61,21 @@ func seedAdmin(ctx context.Context, database *sql.DB, cfg config.Config) error {
if err != nil {
return fmt.Errorf("hash admin password: %w", err)
}
subsonicSecret, err := auth.EncryptSubsonicSecret(cfg.DefaultAdminPassword, cfg.EncryptionKey)
if err != nil {
return fmt.Errorf("encrypt admin subsonic secret: %w", err)
}
now := time.Now().UTC().Format(time.RFC3339)
_, err = database.ExecContext(
ctx,
`INSERT INTO users (id, username, password_hash, is_admin, created_at, last_login_at)
VALUES (?, ?, ?, 1, ?, ?)`,
`INSERT INTO users (id, username, password_hash, subsonic_auth_secret, is_admin, created_at, last_login_at)
VALUES (?, ?, ?, ?, 1, ?, ?)`,
"user-admin",
cfg.DefaultAdminUsername,
string(passwordHash),
subsonicSecret,
now,
now,
)