diff --git a/README.md b/README.md index 31fa060..a71d0bb 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ A library path must be an absolute, existing folder, never the filesystem root, ## Security notes - Sonda listens on localhost only, unless you change `server.listen`. To use it from other machines, put it behind a reverse proxy that terminates HTTPS. -- Passwords are hashed with Argon2id. Refresh tokens are stored only as hashes. +- Passwords are hashed with Argon2id. Refresh tokens are stored only as hashes. An access token is checked against the database on every request, so it stops working as soon as its account is deleted, even if the same user id is given to a new account. - Music folders are read-only to Sonda. Streaming opens files through `os.Root`, so a path can never leave its library, even if a symlink is swapped in later. - File paths are never returned by the catalog, and audio file paths are not logged. - Provider API keys are write-only through the API and never logged. They sit in the database, so protect your backups. diff --git a/internal/api/http/middleware.go b/internal/api/http/middleware.go index 3359f5c..0f27cc5 100644 --- a/internal/api/http/middleware.go +++ b/internal/api/http/middleware.go @@ -78,12 +78,18 @@ func requireAdmin(users userLookup) gin.HandlerFunc { } } -// requireAuth checks the access token. It reads "Authorization: Bearer "; +// requireAuth checks the access token, then that it was issued for the account +// that has this id now. User ids can be given again after an account is deleted +// (SQLite reuses the highest one), and a token lives for minutes: without this check +// the token of a deleted user would work as whoever gets the id next. The account +// must exist, have the same name, and not have been created after the token was signed. +// +// It reads "Authorization: Bearer "; // when allowQuery is true and the header is absent it also accepts the // access_token query parameter. That is for routes loaded by an