From a58f3fc2258614917b3345d5c3901ff38c8c5ae3 Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Thu, 12 Nov 2026 17:36:04 -0800 Subject: [PATCH 1/2] Allow explicit exclusion of runner session headers --- orchestrator/app.go | 5 ----- orchestrator/app_test.go | 16 +++++++++------- orchestrator/http_test.go | 13 +++++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/orchestrator/app.go b/orchestrator/app.go index 297bcd3..9ca0051 100644 --- a/orchestrator/app.go +++ b/orchestrator/app.go @@ -215,11 +215,6 @@ func validateExcludedHeaders(patterns []string) error { } } } - for _, name := range []string{"Livepeer-Runner-Route", "Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"} { - if headerExcluded(name, patterns) { - return fmt.Errorf("--excluded-headers must not remove required header %s", name) - } - } return nil } diff --git a/orchestrator/app_test.go b/orchestrator/app_test.go index aa1ee06..63ec36c 100644 --- a/orchestrator/app_test.go +++ b/orchestrator/app_test.go @@ -293,15 +293,15 @@ func TestLocalOrchestratorWaitsForEconomicalRedemption(t *testing.T) { } func TestExcludedHeadersEnvironmentAndFlag(t *testing.T) { - t.Setenv("LIVEPEER_ORCHESTRATOR_EXCLUDED_HEADERS", "CF-Access-*,Cookie") - for _, args := range [][]string{nil, {"--excluded-headers", "X-Ingress-Token"}} { + t.Setenv("LIVEPEER_ORCHESTRATOR_EXCLUDED_HEADERS", "CF-Access-*,Cookie,Livepeer-Session-*") + for _, args := range [][]string{nil, {"--excluded-headers", "Livepeer-Runner-Route"}} { output, err := execute(t, append([]string{"--config", "", "--print-config"}, args...)...) require.NoError(t, err) var printed Params require.NoError(t, toml.Unmarshal([]byte(output), &printed)) - want := []string{"CF-Access-*", "Cookie"} + want := []string{"CF-Access-*", "Cookie", "Livepeer-Session-*"} if len(args) > 0 { - want = []string{"X-Ingress-Token"} + want = []string{"Livepeer-Runner-Route"} } require.Equal(t, want, printed.ExcludedHeaders) } @@ -328,12 +328,14 @@ func TestExcludedCookiesEnvironmentAndFlag(t *testing.T) { func TestExcludedHeadersValidation(t *testing.T) { require.NoError(t, validateExcludedHeaders(nil)) - require.NoError(t, validateExcludedHeaders([]string{"CF-Access-*", "Cookie", "X-Exact", "X_Valid!#$%&'+-.^`|~"})) + require.NoError(t, validateExcludedHeaders([]string{ + "CF-Access-*", "Cookie", "X-Exact", "X_Valid!#$%&'+-.^`|~", + "livepeer-runner-route", "LIVEPEER-SESSION-ID", "Livepeer-Session-Token", "Livepeer-Session-Control", + "livepeer-*", "Livepeer-Session-*", "L*", + })) t.Setenv("LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET", "test") for _, pattern := range []string{ "", "*", "CF-*-Access", "CF-Access-**", "Bad Header", "Header: value", "Header\r\n", "Héader", - "livepeer-runner-route", "LIVEPEER-SESSION-ID", "Livepeer-Session-Token", "Livepeer-Session-Control", - "livepeer-*", "Livepeer-Session-*", "L*", } { t.Run(fmt.Sprintf("%q", pattern), func(t *testing.T) { require.ErrorContains(t, validateExcludedHeaders([]string{pattern}), "--excluded-headers") diff --git a/orchestrator/http_test.go b/orchestrator/http_test.go index 12ea281..a0773e4 100644 --- a/orchestrator/http_test.go +++ b/orchestrator/http_test.go @@ -173,8 +173,8 @@ func TestProxyExcludedHeaders(t *testing.T) { for _, template := range []string{"", "https://{proxy}.apps.example", "https://orch.example/custom/{proxy}"} { for _, excluded := range []struct{ headers, cookies []string }{ {}, - {headers: []string{"cF-aCCess-*", "x-ingress-token", "cOOkie", "accept-encoding", "user-agent"}}, - {headers: []string{"CF-Access-*", "X-Ingress-Token", "Cookie", "Accept-*", "User-*"}}, + {headers: []string{"cF-aCCess-*", "x-ingress-token", "cOOkie", "accept-encoding", "user-agent", "livepeer-session-*"}}, + {headers: []string{"CF-Access-*", "X-Ingress-Token", "Cookie", "Accept-*", "User-*", "Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"}}, {cookies: []string{"CF_Authorization"}}, } { patterns := excluded.headers @@ -242,8 +242,13 @@ func TestProxyExcludedHeaders(t *testing.T) { require.Equal(t, "payment", received.Get("Livepeer-Payment")) require.Equal(t, "keep", received.Get("X-Ingress-Token-Extra")) require.Equal(t, "keep", received.Get("Cf-Access")) - for _, name := range []string{"Livepeer-Runner-Route", "Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"} { - require.NotEmpty(t, received.Get(name)) + require.NotEmpty(t, received.Get("Livepeer-Runner-Route")) + for _, name := range []string{"Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"} { + if len(patterns) > 0 { + require.Empty(t, received.Get(name)) + } else { + require.NotEmpty(t, received.Get(name)) + } } } }) From 7b650d96ab6022bd7b10d29e28d9d77e2f207041 Mon Sep 17 00:00:00 2001 From: Josh Allmann Date: Thu, 12 Nov 2026 17:44:46 -0800 Subject: [PATCH 2/2] Drop redundant session header exclusion test changes --- orchestrator/app_test.go | 14 +++++--------- orchestrator/http_test.go | 13 ++++--------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/orchestrator/app_test.go b/orchestrator/app_test.go index 63ec36c..b07a176 100644 --- a/orchestrator/app_test.go +++ b/orchestrator/app_test.go @@ -293,15 +293,15 @@ func TestLocalOrchestratorWaitsForEconomicalRedemption(t *testing.T) { } func TestExcludedHeadersEnvironmentAndFlag(t *testing.T) { - t.Setenv("LIVEPEER_ORCHESTRATOR_EXCLUDED_HEADERS", "CF-Access-*,Cookie,Livepeer-Session-*") - for _, args := range [][]string{nil, {"--excluded-headers", "Livepeer-Runner-Route"}} { + t.Setenv("LIVEPEER_ORCHESTRATOR_EXCLUDED_HEADERS", "CF-Access-*,Cookie") + for _, args := range [][]string{nil, {"--excluded-headers", "X-Ingress-Token"}} { output, err := execute(t, append([]string{"--config", "", "--print-config"}, args...)...) require.NoError(t, err) var printed Params require.NoError(t, toml.Unmarshal([]byte(output), &printed)) - want := []string{"CF-Access-*", "Cookie", "Livepeer-Session-*"} + want := []string{"CF-Access-*", "Cookie"} if len(args) > 0 { - want = []string{"Livepeer-Runner-Route"} + want = []string{"X-Ingress-Token"} } require.Equal(t, want, printed.ExcludedHeaders) } @@ -328,11 +328,7 @@ func TestExcludedCookiesEnvironmentAndFlag(t *testing.T) { func TestExcludedHeadersValidation(t *testing.T) { require.NoError(t, validateExcludedHeaders(nil)) - require.NoError(t, validateExcludedHeaders([]string{ - "CF-Access-*", "Cookie", "X-Exact", "X_Valid!#$%&'+-.^`|~", - "livepeer-runner-route", "LIVEPEER-SESSION-ID", "Livepeer-Session-Token", "Livepeer-Session-Control", - "livepeer-*", "Livepeer-Session-*", "L*", - })) + require.NoError(t, validateExcludedHeaders([]string{"CF-Access-*", "Cookie", "X-Exact", "X_Valid!#$%&'+-.^`|~"})) t.Setenv("LIVEPEER_ORCHESTRATOR_BOOTSTRAP_SECRET", "test") for _, pattern := range []string{ "", "*", "CF-*-Access", "CF-Access-**", "Bad Header", "Header: value", "Header\r\n", "Héader", diff --git a/orchestrator/http_test.go b/orchestrator/http_test.go index a0773e4..12ea281 100644 --- a/orchestrator/http_test.go +++ b/orchestrator/http_test.go @@ -173,8 +173,8 @@ func TestProxyExcludedHeaders(t *testing.T) { for _, template := range []string{"", "https://{proxy}.apps.example", "https://orch.example/custom/{proxy}"} { for _, excluded := range []struct{ headers, cookies []string }{ {}, - {headers: []string{"cF-aCCess-*", "x-ingress-token", "cOOkie", "accept-encoding", "user-agent", "livepeer-session-*"}}, - {headers: []string{"CF-Access-*", "X-Ingress-Token", "Cookie", "Accept-*", "User-*", "Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"}}, + {headers: []string{"cF-aCCess-*", "x-ingress-token", "cOOkie", "accept-encoding", "user-agent"}}, + {headers: []string{"CF-Access-*", "X-Ingress-Token", "Cookie", "Accept-*", "User-*"}}, {cookies: []string{"CF_Authorization"}}, } { patterns := excluded.headers @@ -242,13 +242,8 @@ func TestProxyExcludedHeaders(t *testing.T) { require.Equal(t, "payment", received.Get("Livepeer-Payment")) require.Equal(t, "keep", received.Get("X-Ingress-Token-Extra")) require.Equal(t, "keep", received.Get("Cf-Access")) - require.NotEmpty(t, received.Get("Livepeer-Runner-Route")) - for _, name := range []string{"Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"} { - if len(patterns) > 0 { - require.Empty(t, received.Get(name)) - } else { - require.NotEmpty(t, received.Get(name)) - } + for _, name := range []string{"Livepeer-Runner-Route", "Livepeer-Session-Id", "Livepeer-Session-Token", "Livepeer-Session-Control"} { + require.NotEmpty(t, received.Get(name)) } } })