From 57015e2bf0c53bbf566ece3214b42e2e210f1043 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 14 Dec 2022 19:06:49 +0100 Subject: [PATCH] fix authentication with VLC This fixes the case in which VLC is trying to read a path with a query (i.e. stream?mykey=myval) and the path requires read credentials. --- internal/core/rtsp_session.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/core/rtsp_session.go b/internal/core/rtsp_session.go index ae30125f..61e5c115 100644 --- a/internal/core/rtsp_session.go +++ b/internal/core/rtsp_session.go @@ -191,17 +191,18 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt pathPass conf.Credential, ) error { baseURL := &url.URL{ - Scheme: ctx.Request.URL.Scheme, - Host: ctx.Request.URL.Host, - Path: func() string { - pa := ctx.Path - if ctx.Query != "" { - pa += "?" + ctx.Query - } - pa += "/" - return pa - }(), + Scheme: ctx.Request.URL.Scheme, + Host: ctx.Request.URL.Host, + Path: ctx.Path, + RawQuery: ctx.Query, } + + if ctx.Query != "" { + baseURL.RawQuery += "/" + } else { + baseURL.Path += "/" + } + return c.authenticate(ctx.Path, ctx.Query, pathIPs, pathUser, pathPass, false, ctx.Request, baseURL) }, })