feat: OpenSubsonic core, login with a device password

/rest speaks the OpenSubsonic API (Subsonic 1.16.1) so that other apps can browse
the music of a server. A call logs in with the password of a device: an apiKey,
Subsonic's token (u, t, s) or the password itself (u, p). The account password is
never accepted there.

- devices: ByKey, ByToken, ByPassword and the note of last use
- opensubsonic package: JSON and XML answers, ping, getLicense,
  getOpenSubsonicExtensions, tokenInfo, getMusicFolders, getArtists, getArtist,
  getAlbum, getSong, getGenres
- storage.SubsonicRepo: year, genres, size, bitrate, suffix and added date
This commit is contained in:
tgiachi 2026-11-16 09:32:11 +01:00
commit 1ae8e77d81

View file

@ -34,6 +34,7 @@ import (
"git.kmalloc.org/squid/sonda/internal/mastodon"
"git.kmalloc.org/squid/sonda/internal/mixes"
"git.kmalloc.org/squid/sonda/internal/naming"
"git.kmalloc.org/squid/sonda/internal/opensubsonic"
"git.kmalloc.org/squid/sonda/internal/playlists"
"git.kmalloc.org/squid/sonda/internal/providers"
"git.kmalloc.org/squid/sonda/internal/providers/anthropic"
@ -299,18 +300,26 @@ func run() error {
mastodonSvc := mastodon.NewService(storage.NewMastodonRepo(db), mastodon.NewRemote(providers.UserAgent(version, "")), logger)
go mastodonSvc.Run(ctx)
// Other apps (OpenSubsonic) log in with the password of a device, never with the account password.
deviceSvc := devices.NewService(storage.NewDevicesRepo(db), []byte(cfg.Auth.JWTSecret))
catalogSvc := catalog.NewService(storage.NewCatalogRepo(db))
router := httpapi.NewRouter(httpapi.Deps{
Logger: logger,
Build: build(),
Stats: stats.NewService(storage.NewStatsRepo(db), cfg.Listening.MinListen()),
Auth: auth.NewService(storage.NewUserRepo(db), storage.NewRefreshRepo(db), tokens, cfg.Auth.RefreshTTL()),
Tokens: tokens,
Listening: listening.NewService(storage.NewListeningRepo(db), cfg.Listening.MinListen()),
Mastodon: mastodonSvc,
Devices: devices.NewService(storage.NewDevicesRepo(db), []byte(cfg.Auth.JWTSecret)),
Logger: logger,
Build: build(),
Stats: stats.NewService(storage.NewStatsRepo(db), cfg.Listening.MinListen()),
Auth: auth.NewService(storage.NewUserRepo(db), storage.NewRefreshRepo(db), tokens, cfg.Auth.RefreshTTL()),
Tokens: tokens,
Listening: listening.NewService(storage.NewListeningRepo(db), cfg.Listening.MinListen()),
Mastodon: mastodonSvc,
Devices: deviceSvc,
OpenSubsonic: &opensubsonic.Deps{
Login: deviceSvc, Catalog: catalogSvc, Libraries: libraries,
Extras: storage.NewSubsonicRepo(db), ServerVersion: version,
},
Scan: scanControl{ctx: ctx, m: scans},
Libraries: libraries,
Catalog: catalog.NewService(storage.NewCatalogRepo(db)),
Catalog: catalogSvc,
Providers: providerSettings,
Lidarr: lidarrClient,
LidarrArtists: lidarr.NewService(discoveryRepo, providerSettings, lidarrClient),