fix(stream): let a stream token authorize direct/remux delivery - #216
Merged
Merged
Conversation
HandleStream required a user before anything else, so a request that
StreamTokenAuth had already authorized with a session-bound ?st= grant
(and no bearer, by design) was rejected 401 "Authentication required".
The HLS manifest/segment handlers accept that case; the progressive one
did not. Native TV players (Tizen videohole) play the plan URL verbatim,
so every direct-play and progressive-remux start 401'd, the client's
failure recovery fell through to an encode, and HDR sources then ended
on "no validated HDR-preserving or tone-map recipe".
Reproduced against the live server with a real plan token: 206 on the
root /stream/{id} route, 401 on /api/v1 and /api/v2/stream/{id}.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom: Tizen: Roger Rabbit (HDR10, direct play) ends on "This HDR source requires video encoding, but no validated HDR-preserving or tone-map recipe is installed." Iron Man (progressive remux) fails too.
Cause:
HandleStreamrejectsuserID == 0before looking at the session, so a request thatStreamTokenAuthalready authorized via the session-bound?st=grant is 401'd. The HLS manifest/segment handlers accept that case; the progressive/direct one didn't. Tizen plays the plan URL with no bearer, so everyGET /api/v2/stream/{id}401'd (server logs:getPlaybackMedia 401 authentication_required auth_class=anonymous), smarttv's failure recovery replanned to copy-HLS (Not supported formatfor this DV/HDR source), and the final replan refused with the tone-map message.Reproduced on the live server with a real plan token:
206on root/stream/{id},401on/api/v1/stream/{id}and/api/v2/stream/{id}.Fix: allow
userID == 0whenapimw.IsStreamTokenAuthorized. The session load still enforces the session's media-authorization mode (header-auth sessions still require a user) and ownership when an identity is present.Test:
TestHandleStream_StreamTokenAuthorizesAnonymousDeliveryruns the real middleware: no credential → 401, token for another session → 401, bound token → 200. Invariant anchor added.🤖 Generated with Claude Code