From 291353b1e3e9829f7117f542aa2983ddfb833d15 Mon Sep 17 00:00:00 2001 From: "user.email" Date: Sat, 24 Oct 2026 09:52:12 -0700 Subject: [PATCH] hlsts: carry the jwt query credential into generated segment URLs Players fetching the playlist with ?jwt=... authenticate each segment through the same query parameter; without it every segment 401s. --- weed/format/hlsts/hlsts.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/weed/format/hlsts/hlsts.go b/weed/format/hlsts/hlsts.go index 5dac4fcab5..5c4ccfb4bf 100644 --- a/weed/format/hlsts/hlsts.go +++ b/weed/format/hlsts/hlsts.go @@ -255,7 +255,7 @@ func (Adapter) View(req format.ViewRequest, obj format.Object) (*format.ViewPlan } sequenceText := req.Query.Get("seq") if sequenceText == "" { - return &format.ViewPlan{ContentType: PlaylistContentType, Body: renderPlaylist(obj.Name, info)}, nil + return &format.ViewPlan{ContentType: PlaylistContentType, Body: renderPlaylist(obj.Name, info, req.Query.Get("jwt"))}, nil } sequence, err := strconv.ParseInt(sequenceText, 10, 64) if err != nil || sequence < info.MediaSequence { @@ -268,16 +268,20 @@ func (Adapter) View(req format.ViewRequest, obj format.Object) (*format.ViewPlan return &format.ViewPlan{ContentType: MediaContentType, Extent: int(index)}, nil } -func renderPlaylist(name string, info *playlistInfo) []byte { +func renderPlaylist(name string, info *playlistInfo, jwt string) []byte { var out strings.Builder out.WriteString("#EXTM3U\n#EXT-X-VERSION:3\n") fmt.Fprintf(&out, "#EXT-X-TARGETDURATION:%d\n", info.TargetDuration) fmt.Fprintf(&out, "#EXT-X-MEDIA-SEQUENCE:%d\n", info.MediaSequence) out.WriteString("#EXT-X-PLAYLIST-TYPE:VOD\n") escapedName := url.PathEscape(name) + credential := "" + if jwt != "" { + credential = "&jwt=" + url.QueryEscape(jwt) + } for i, durationMs := range info.DurationsMs { fmt.Fprintf(&out, "#EXTINF:%.3f,\n", float64(durationMs)/1000) - fmt.Fprintf(&out, "%s?%s=%s&seq=%d\n", escapedName, format.ViewParam, FormatName, int64(i)+info.MediaSequence) + fmt.Fprintf(&out, "%s?%s=%s&seq=%d%s\n", escapedName, format.ViewParam, FormatName, int64(i)+info.MediaSequence, credential) } out.WriteString("#EXT-X-ENDLIST\n") return []byte(out.String())