Skip to content

Add per-user Trakt self-service (link, prefs, optional token export) - #307

Closed
selmant wants to merge 8 commits into
jellyfin:masterfrom
selmant:feature/user-self-service
Closed

selmant wants to merge 8 commits into
jellyfin:masterfrom
selmant:feature/user-self-service

Conversation

@selmant

@selmant selmant commented Jul 25, 2026 •

Copy link
Copy Markdown

Summary

Adds per-user Trakt self-service without giving users access to the Jellyfin admin dashboard.

  • Users can link or unlink Trakt and manage their own sync/scrobble preferences at /Trakt/SelfService.
  • Existing /Trakt/Users/{userGuid}/… routes now require the same user or an administrator, closing cross-user access to rating and recommendation actions.
  • Debug logging, excluded folders, and access-token export remain administrator-controlled.

Fixes #221.
Fixes #294.

Details

The plugin serves a standalone self-service page because jellyfin-web restricts plugin configuration pages to administrators. The HTML can load anonymously, but every /Trakt/me* API call requires the user's Jellyfin session. Stored credentials are matched to the server serving the page, including installations with a base URL.

New endpoints:

Method Path Purpose
GET /Trakt/me Link status and user-editable preferences
POST /Trakt/me/Authorize Start Trakt device authorization
GET /Trakt/me/PollAuthorizationStatus Wait for device authorization
POST /Trakt/me/Deauthorize Unlink Trakt while keeping preferences
PUT /Trakt/me/Settings Save user-editable preferences
GET /Trakt/me/Token Export a valid access token when an admin allows it

The admin page exposes the self-service URL and two opt-in token-export controls: a default for new Trakt user configs and a per-user override. Token export is disabled by default, never returns the refresh token, and revalidates token expiry after refresh.

Deauthorization now waits for Trakt's revoke request before clearing local credentials, while preserving the user's preferences. Administrator API keys remain valid for user-scoped admin operations.

The plugin does not modify jellyfin-web config.json. Administrators may optionally add /Trakt/SelfService through jellyfin-web menuLinks.

Upgrade safety

  • New configuration fields default to false.
  • Existing tokens and preferences are unchanged.
  • Reading /Trakt/me does not create a user configuration.

Test plan

  • Release publish succeeds with the .NET 9 SDK and analyzers enabled
  • git diff --check
  • Standalone page inline JavaScript parses successfully
  • Open the admin page on Jellyfin 10.11 and copy the self-service URL
  • Link, save preferences, reload, and unlink as a non-admin user
  • Verify another user's /Trakt/Users/{userGuid}/… routes return 403
  • Verify an administrator user and administrator API key can access user-scoped routes
  • Verify token export is forbidden by default and returns only a current access token after admin opt-in
  • Verify installations with multiple saved servers and a configured base URL select the current server

selmant and others added 2 commits July 26, 2026 02:36
Serve a standalone /Trakt/SelfService page and /Trakt/me APIs so users can
link accounts and manage sync prefs; keep token export, debug logging, and
folder exclusions admin-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@selmant
selmant marked this pull request as draft July 26, 2026 00:07
selmant and others added 6 commits July 26, 2026 04:44
Keep the PR focused on per-user self-service and ownership auth; username display can land separately if wanted.

Co-authored-by: Cursor <cursoragent@cursor.com>
Screenshots stay local for manual PR attachment; drop the drive-by default flips from the self-service change.

Co-authored-by: Cursor <cursoragent@cursor.com>
That path is personal workflow only and does not belong upstream.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep personal docker-dev paths out of the upstream self-service change.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the legacy empty-UserName cleanup and drop drive-by default-object edits unrelated to self-service.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zotabee

zotabee commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Any news @selmant ?

@selmant

selmant commented Oct 17, 2026

Copy link
Copy Markdown
Author

Hi @zotabee, we had a conversation with the Jellyfin team on Discord, and it seems they're definitely not interested in merging or working on this.

Since I don't want to deal with the AI drama and all that, I decided to fork it and make it a drop-in replacement.

I'd encourage you to push for this in the official Jellyfin Discord or simply use the fork instead: https://github.com/selmant/better-trakt

@selmant selmant closed this Oct 17, 2026
@selmant

selmant commented Oct 17, 2026

Copy link
Copy Markdown
Author

Also, I saw your PRs, and unfortunately, I'm pretty sure they won't get merged either. Would you mind if I took those changes and included them in my fork?

@zotabee

zotabee commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for letting me know, and sorry #307 ended up closed.

Of course, take whatever you like from my PRs! The more alternatives the better, and that's what open source is for. A mention in the commit or release notes would be nice.

A few of my earlier PRs (#277 to #279) did get merged here, so I'll leave #320 to #337 open and give them a chance. They're small and easy to review: most are targeted fixes, and each one was tested before I pushed it. Upstream master hasn't moved since v33, and all my branches merge together onto it and build without warnings, so you can take them in any order. There are also three fixes on my fork that I haven't opened as PRs yet: remove-deleted-series, keep-import-cancellation and skip-empty-not-found-retry.

One thing: I'm going to run all of them on my own server for a while first, so it might be worth waiting until I report back before you merge them.

Issues are turned off on better-trakt. Where would you like bug reports or PRs?

@zotabee

zotabee commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

As promised, I've been running all my branches on my server (Jellyfin 12.1) since 2026-10-18:

Everything is in PRs #320–#343 here. 19 of the 23 branches apply cleanly onto better-trakt; 4 need a small rebase (README, TraktApi.cs, trakt.html). Would you rather get PRs against better-trakt, or cherry-pick them yourself?

@selmant

selmant commented Oct 23, 2026

Copy link
Copy Markdown
Author

Thanks a lot @zotabee, and thanks for testing everything on your server first!

I merged your PRs myself, so no need to open new ones. All of #320–#343 except the README one (#325) went into Better Trakt 1000.2026.1023.1. Each one is a separate merge commit that keeps your original commits, and you're credited in the release notes, the changelog and the README.

A few spots needed adapting to the fork:

Something you might run into on your branches too: 12.*-* now restores the Jellyfin 12.3.0 packages, so the built DLL wouldn't load on 12.1 or 12.2 even though targetAbi is 12.1. The fork now pins 12.1.0.

Issues are now open on better-trakt, so please send bug reports there. PRs are welcome against the better-trakt branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] [security] Trakt userGuid endpoints should enforce current-user-or-admin authorization Handling multiple users

2 participants