Browse Source

restore sending session ID to external authentication (#1871)

this fixes a regression introduced in v0.23.0
pull/1872/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
7d04742426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      internal/core/authentication.go
  2. 10
      internal/core/hls_manager_test.go
  3. 10
      internal/core/rtmp_server_test.go
  4. 13
      internal/core/rtsp_server_test.go
  5. 16
      internal/highleveltests/hls_server_test.go

1
internal/core/authentication.go

@ -69,6 +69,7 @@ func externalAuth(
Password: password, Password: password,
Path: path, Path: path,
Protocol: string(protocol), Protocol: string(protocol),
ID: id,
Action: func() string { Action: func() string {
if publish { if publish {
return "publish" return "publish"

10
internal/core/hls_manager_test.go

@ -24,11 +24,9 @@ type testHTTPAuthenticator struct {
s *http.Server s *http.Server
} }
func newTestHTTPAuthenticator(protocol string, action string) (*testHTTPAuthenticator, error) { func newTestHTTPAuthenticator(t *testing.T, protocol string, action string) *testHTTPAuthenticator {
ln, err := net.Listen("tcp", "127.0.0.1:9120") ln, err := net.Listen("tcp", "127.0.0.1:9120")
if err != nil { require.NoError(t, err)
return nil, err
}
ts := &testHTTPAuthenticator{ ts := &testHTTPAuthenticator{
protocol: protocol, protocol: protocol,
@ -41,7 +39,7 @@ func newTestHTTPAuthenticator(protocol string, action string) (*testHTTPAuthenti
ts.s = &http.Server{Handler: router} ts.s = &http.Server{Handler: router}
go ts.s.Serve(ln) go ts.s.Serve(ln)
return ts, nil return ts
} }
func (ts *testHTTPAuthenticator) close() { func (ts *testHTTPAuthenticator) close() {
@ -55,6 +53,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
Password string `json:"password"` Password string `json:"password"`
Path string `json:"path"` Path string `json:"path"`
Protocol string `json:"protocol"` Protocol string `json:"protocol"`
ID string `json:"id"`
Action string `json:"action"` Action string `json:"action"`
Query string `json:"query"` Query string `json:"query"`
} }
@ -76,6 +75,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
in.Password != "testpass" || in.Password != "testpass" ||
in.Path != "teststream" || in.Path != "teststream" ||
in.Protocol != ts.protocol || in.Protocol != ts.protocol ||
in.ID == "" ||
in.Action != ts.action || in.Action != ts.action ||
(in.Query != "user=testreader&pass=testpass&param=value" && (in.Query != "user=testreader&pass=testpass&param=value" &&
in.Query != "user=testpublisher&pass=testpass&param=value" && in.Query != "user=testpublisher&pass=testpass&param=value" &&

10
internal/core/rtmp_server_test.go

@ -209,9 +209,7 @@ func TestRTMPServerAuth(t *testing.T) {
var a *testHTTPAuthenticator var a *testHTTPAuthenticator
if ca == "external" { if ca == "external" {
var err error a = newTestHTTPAuthenticator(t, "rtmp", "publish")
a, err = newTestHTTPAuthenticator("rtmp", "publish")
require.NoError(t, err)
} }
u1, err := url.Parse("rtmp://127.0.0.1:1935/teststream?user=testpublisher&pass=testpass&param=value") u1, err := url.Parse("rtmp://127.0.0.1:1935/teststream?user=testpublisher&pass=testpass&param=value")
@ -245,8 +243,7 @@ func TestRTMPServerAuth(t *testing.T) {
if ca == "external" { if ca == "external" {
a.close() a.close()
a, err = newTestHTTPAuthenticator("rtmp", "read") a = newTestHTTPAuthenticator(t, "rtmp", "read")
require.NoError(t, err)
defer a.close() defer a.close()
} }
@ -330,8 +327,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
require.Equal(t, true, ok) require.Equal(t, true, ok)
defer p.Close() defer p.Close()
a, err := newTestHTTPAuthenticator("rtmp", "publish") a := newTestHTTPAuthenticator(t, "rtmp", "publish")
require.NoError(t, err)
defer a.close() defer a.close()
u1, err := url.Parse("rtmp://127.0.0.1:1935/teststream?user=testuser1&pass=testpass") u1, err := url.Parse("rtmp://127.0.0.1:1935/teststream?user=testuser1&pass=testpass")

13
internal/core/rtsp_server_test.go

@ -71,9 +71,7 @@ func TestRTSPServerAuth(t *testing.T) {
var a *testHTTPAuthenticator var a *testHTTPAuthenticator
if ca == "external" { if ca == "external" {
var err error a = newTestHTTPAuthenticator(t, "rtsp", "publish")
a, err = newTestHTTPAuthenticator("rtsp", "publish")
require.NoError(t, err)
} }
medi := testMediaH264 medi := testMediaH264
@ -88,9 +86,7 @@ func TestRTSPServerAuth(t *testing.T) {
if ca == "external" { if ca == "external" {
a.close() a.close()
var err error a = newTestHTTPAuthenticator(t, "rtsp", "read")
a, err = newTestHTTPAuthenticator("rtsp", "read")
require.NoError(t, err)
defer a.close() defer a.close()
} }
@ -257,15 +253,14 @@ func TestRTSPServerAuthFail(t *testing.T) {
require.Equal(t, true, ok) require.Equal(t, true, ok)
defer p.Close() defer p.Close()
a, err := newTestHTTPAuthenticator("rtsp", "publish") a := newTestHTTPAuthenticator(t, "rtsp", "publish")
require.NoError(t, err)
defer a.close() defer a.close()
medi := testMediaH264 medi := testMediaH264
c := gortsplib.Client{} c := gortsplib.Client{}
err = c.StartRecording( err := c.StartRecording(
"rtsp://testpublisher2:testpass@localhost:8554/teststream?param=value", "rtsp://testpublisher2:testpass@localhost:8554/teststream?param=value",
media.Medias{medi}, media.Medias{medi},
) )

16
internal/highleveltests/hls_server_test.go

@ -21,11 +21,9 @@ type testHTTPAuthenticator struct {
s *http.Server s *http.Server
} }
func newTestHTTPAuthenticator(action string) (*testHTTPAuthenticator, error) { func newTestHTTPAuthenticator(t *testing.T, action string) *testHTTPAuthenticator {
ln, err := net.Listen("tcp", "127.0.0.1:9120") ln, err := net.Listen("tcp", "127.0.0.1:9120")
if err != nil { require.NoError(t, err)
return nil, err
}
ts := &testHTTPAuthenticator{ ts := &testHTTPAuthenticator{
action: action, action: action,
@ -37,7 +35,7 @@ func newTestHTTPAuthenticator(action string) (*testHTTPAuthenticator, error) {
ts.s = &http.Server{Handler: router} ts.s = &http.Server{Handler: router}
go ts.s.Serve(ln) go ts.s.Serve(ln)
return ts, nil return ts
} }
func (ts *testHTTPAuthenticator) close() { func (ts *testHTTPAuthenticator) close() {
@ -138,9 +136,7 @@ func TestHLSServerAuth(t *testing.T) {
var a *testHTTPAuthenticator var a *testHTTPAuthenticator
if mode == "external" { if mode == "external" {
var err error a = newTestHTTPAuthenticator(t, "publish")
a, err = newTestHTTPAuthenticator("publish")
require.NoError(t, err)
} }
cnt1, err := newContainer("ffmpeg", "source", []string{ cnt1, err := newContainer("ffmpeg", "source", []string{
@ -158,9 +154,7 @@ func TestHLSServerAuth(t *testing.T) {
if mode == "external" { if mode == "external" {
a.close() a.close()
var err error a = newTestHTTPAuthenticator(t, "read")
a, err = newTestHTTPAuthenticator("read")
require.NoError(t, err)
defer a.close() defer a.close()
} }

Loading…
Cancel
Save