feat: add subsonic token auth and starred endpoints
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user