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

10
internal/core/hls_manager_test.go

@ -24,11 +24,9 @@ type testHTTPAuthenticator struct { @@ -24,11 +24,9 @@ type testHTTPAuthenticator struct {
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")
if err != nil {
return nil, err
}
require.NoError(t, err)
ts := &testHTTPAuthenticator{
protocol: protocol,
@ -41,7 +39,7 @@ func newTestHTTPAuthenticator(protocol string, action string) (*testHTTPAuthenti @@ -41,7 +39,7 @@ func newTestHTTPAuthenticator(protocol string, action string) (*testHTTPAuthenti
ts.s = &http.Server{Handler: router}
go ts.s.Serve(ln)
return ts, nil
return ts
}
func (ts *testHTTPAuthenticator) close() {
@ -55,6 +53,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) { @@ -55,6 +53,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
Password string `json:"password"`
Path string `json:"path"`
Protocol string `json:"protocol"`
ID string `json:"id"`
Action string `json:"action"`
Query string `json:"query"`
}
@ -76,6 +75,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) { @@ -76,6 +75,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
in.Password != "testpass" ||
in.Path != "teststream" ||
in.Protocol != ts.protocol ||
in.ID == "" ||
in.Action != ts.action ||
(in.Query != "user=testreader&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) { @@ -209,9 +209,7 @@ func TestRTMPServerAuth(t *testing.T) {
var a *testHTTPAuthenticator
if ca == "external" {
var err error
a, err = newTestHTTPAuthenticator("rtmp", "publish")
require.NoError(t, err)
a = newTestHTTPAuthenticator(t, "rtmp", "publish")
}
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) { @@ -245,8 +243,7 @@ func TestRTMPServerAuth(t *testing.T) {
if ca == "external" {
a.close()
a, err = newTestHTTPAuthenticator("rtmp", "read")
require.NoError(t, err)
a = newTestHTTPAuthenticator(t, "rtmp", "read")
defer a.close()
}
@ -330,8 +327,7 @@ func TestRTMPServerAuthFail(t *testing.T) { @@ -330,8 +327,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
require.Equal(t, true, ok)
defer p.Close()
a, err := newTestHTTPAuthenticator("rtmp", "publish")
require.NoError(t, err)
a := newTestHTTPAuthenticator(t, "rtmp", "publish")
defer a.close()
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) { @@ -71,9 +71,7 @@ func TestRTSPServerAuth(t *testing.T) {
var a *testHTTPAuthenticator
if ca == "external" {
var err error
a, err = newTestHTTPAuthenticator("rtsp", "publish")
require.NoError(t, err)
a = newTestHTTPAuthenticator(t, "rtsp", "publish")
}
medi := testMediaH264
@ -88,9 +86,7 @@ func TestRTSPServerAuth(t *testing.T) { @@ -88,9 +86,7 @@ func TestRTSPServerAuth(t *testing.T) {
if ca == "external" {
a.close()
var err error
a, err = newTestHTTPAuthenticator("rtsp", "read")
require.NoError(t, err)
a = newTestHTTPAuthenticator(t, "rtsp", "read")
defer a.close()
}
@ -257,15 +253,14 @@ func TestRTSPServerAuthFail(t *testing.T) { @@ -257,15 +253,14 @@ func TestRTSPServerAuthFail(t *testing.T) {
require.Equal(t, true, ok)
defer p.Close()
a, err := newTestHTTPAuthenticator("rtsp", "publish")
require.NoError(t, err)
a := newTestHTTPAuthenticator(t, "rtsp", "publish")
defer a.close()
medi := testMediaH264
c := gortsplib.Client{}
err = c.StartRecording(
err := c.StartRecording(
"rtsp://testpublisher2:testpass@localhost:8554/teststream?param=value",
media.Medias{medi},
)

16
internal/highleveltests/hls_server_test.go

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

Loading…
Cancel
Save