music-assistant-server

Branch:dev-lidarr-plugin

Commit Details

Newly created tokens now show up in the token list (#6131)

# What does this implement/fix?

Creating a token and then not seeing it appear in the token list.

The list is capped at 100 tokens but had no sort order, so SQLite
returned the *oldest* 100 rows and a newly created token fell off the
end. Expired session tokens were also only deleted when that same token
was used again, so nothing ever swept them and the table kept growing
past the cap.

- `auth/tokens` now returns the newest tokens first
- Expired short-lived tokens are pruned at startup and once a day,
alongside the existing join code cleanup
- Long-lived tokens are left alone, so they stay listed until the user
revokes them

No schema change, so no migration needed.

**Related issue (if applicable):**

- n/a, reported directly

## Types of changes

- [x] Bugfix (non-breaking change which fixes an issue) — `bugfix`
- [ ] New feature (non-breaking change which adds functionality) —
`new-feature`
- [ ] Enhancement to an existing feature — `enhancement`
- [ ] New music/player/metadata/plugin provider — `new-provider`
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected) — `breaking-change`
- [ ] Refactor (no behaviour change) — `refactor`
- [ ] Documentation only — `documentation`
- [ ] Maintenance / chore — `maintenance`
- [ ] CI / workflow change — `ci`
- [ ] Dependencies bump — `dependencies`

## Checklist

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `pytest` passes, and tests have been added/updated under `tests/`
where applicable.
- [ ] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [ ] For changes affecting the UI, the companion PR in
`music-assistant/frontend` is linked.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.
Forgejo

Author

Marcel van der Veldt<[email protected]>
August 31, 2026 at 03:14 PM UTC

Committer

Marvin Schenkel<[email protected]>
September 4, 2026 at 07:55 AM UTC
117additions
3deletions
2files changed

Parent commits

Changes

2 files
+117-3

Changed Files (2)

music_assistant/controllers/webserver/
tests/
music_assistant/controllers/webserver/auth.py
+8-3
tests/test_webserver_auth.py
+109