Skip to content

Commit 3eb7b68

Browse files
committed
OCPBUGS-74506: Remove CSP feature flag
1 parent a00af1a commit 3eb7b68

4 files changed

Lines changed: 25 additions & 38 deletions

File tree

cmd/bridge/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func main() {
156156
fPluginProxy := fs.String("plugin-proxy", "", "Defines various service types to which will console proxy plugins requests. (JSON as string)")
157157
fI18NamespacesFlags := fs.String("i18n-namespaces", "", "List of namespaces separated by comma. Example --i18n-namespaces=plugin__acm,plugin__kubevirt")
158158

159-
fContentSecurityPolicyEnabled := fs.Bool("content-security-policy-enabled", true, "Flag to indicate if Content Secrity Policy features should be enabled.")
160159
consoleCSPFlags := serverconfig.MultiKeyValue{}
161160
fs.Var(&consoleCSPFlags, "content-security-policy", "List of CSP directives that are enabled for the console. Each entry consist of csp-directive-name as a key and csp-directive-value as a value. Example --content-security-policy script-src='localhost:9000',font-src='localhost:9001'")
162161

@@ -346,7 +345,6 @@ func main() {
346345
EnabledPluginsOrder: enabledPluginsOrder,
347346
I18nNamespaces: i18nNamespaces,
348347
PluginProxy: *fPluginProxy,
349-
ContentSecurityPolicyEnabled: *fContentSecurityPolicyEnabled,
350348
ContentSecurityPolicy: consoleCSPFlags,
351349
QuickStarts: *fQuickStarts,
352350
AddPage: *fAddPage,

pkg/server/server.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ type Server struct {
166166
ClusterManagementProxyConfig *proxy.Config
167167
CookieEncryptionKey []byte
168168
CookieAuthenticationKey []byte
169-
ContentSecurityPolicyEnabled bool
170169
ContentSecurityPolicy serverconfig.MultiKeyValue
171170
ControlPlaneTopology string
172171
CopiedCSVsDisabled bool
@@ -719,18 +718,16 @@ func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {
719718
panic(err)
720719
}
721720

722-
if s.ContentSecurityPolicyEnabled {
723-
cspDirectives, err := utils.BuildCSPDirectives(
724-
s.K8sMode,
725-
s.ContentSecurityPolicy,
726-
indexPageScriptNonce,
727-
r.Header.Get("Test-CSP-Reporting-Endpoint"),
728-
)
729-
if err != nil {
730-
klog.Fatalf("Error building Content Security Policy directives: %s", err)
731-
}
732-
w.Header().Set("Content-Security-Policy-Report-Only", strings.Join(cspDirectives, "; "))
721+
cspDirectives, err := utils.BuildCSPDirectives(
722+
s.K8sMode,
723+
s.ContentSecurityPolicy,
724+
indexPageScriptNonce,
725+
r.Header.Get("Test-CSP-Reporting-Endpoint"),
726+
)
727+
if err != nil {
728+
klog.Fatalf("Error building Content Security Policy directives: %s", err)
733729
}
730+
w.Header().Set("Content-Security-Policy-Report-Only", strings.Join(cspDirectives, "; "))
734731

735732
jsg := &jsGlobals{
736733
AddPage: s.AddPage,

pkg/serverconfig/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ func SetFlagsFromConfig(fs *flag.FlagSet, config *Config) (err error) {
178178
return err
179179
}
180180

181-
addContentSecurityPolicyEnabled(fs, &config.ContentSecurityPolicyEnabled)
182181
addContentSecurityPolicy(fs, config.ContentSecurityPolicy)
183182
addTelemetry(fs, config.Telemetry)
184183

@@ -481,12 +480,6 @@ func addI18nNamespaces(fs *flag.FlagSet, i18nNamespaces []string) {
481480
fs.Set("i18n-namespaces", strings.Join(i18nNamespaces, ","))
482481
}
483482

484-
func addContentSecurityPolicyEnabled(fs *flag.FlagSet, enabled *bool) {
485-
if enabled != nil && *enabled {
486-
fs.Set("content-security-policy-enabled", "true")
487-
}
488-
}
489-
490483
func SetIfUnset(flagVal *string, val string) {
491484
if len(*flagVal) == 0 {
492485
*flagVal = val

pkg/serverconfig/types.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ import (
1313

1414
// Config is the top-level console server cli configuration.
1515
type Config struct {
16-
APIVersion string `yaml:"apiVersion"`
17-
Kind string `yaml:"kind"`
18-
ServingInfo `yaml:"servingInfo"`
19-
ClusterInfo `yaml:"clusterInfo"`
20-
Auth `yaml:"auth"`
21-
Session `yaml:"session"`
22-
Customization `yaml:"customization"`
23-
Providers `yaml:"providers"`
24-
Helm `yaml:"helm"`
25-
MonitoringInfo `yaml:"monitoringInfo,omitempty"`
26-
Plugins MultiKeyValue `yaml:"plugins,omitempty"`
27-
I18nNamespaces []string `yaml:"i18nNamespaces,omitempty"`
28-
Proxy Proxy `yaml:"proxy,omitempty"`
29-
ContentSecurityPolicyEnabled bool `yaml:"contentSecurityPolicyEnabled,omitempty"`
30-
ContentSecurityPolicy map[consolev1.DirectiveType][]string `yaml:"contentSecurityPolicy,omitempty"`
31-
Telemetry MultiKeyValue `yaml:"telemetry,omitempty"`
32-
PluginsOrder []string `yaml:"pluginsOrder,omitempty"`
16+
APIVersion string `yaml:"apiVersion"`
17+
Kind string `yaml:"kind"`
18+
ServingInfo `yaml:"servingInfo"`
19+
ClusterInfo `yaml:"clusterInfo"`
20+
Auth `yaml:"auth"`
21+
Session `yaml:"session"`
22+
Customization `yaml:"customization"`
23+
Providers `yaml:"providers"`
24+
Helm `yaml:"helm"`
25+
MonitoringInfo `yaml:"monitoringInfo,omitempty"`
26+
Plugins MultiKeyValue `yaml:"plugins,omitempty"`
27+
I18nNamespaces []string `yaml:"i18nNamespaces,omitempty"`
28+
Proxy Proxy `yaml:"proxy,omitempty"`
29+
ContentSecurityPolicy map[consolev1.DirectiveType][]string `yaml:"contentSecurityPolicy,omitempty"`
30+
Telemetry MultiKeyValue `yaml:"telemetry,omitempty"`
31+
PluginsOrder []string `yaml:"pluginsOrder,omitempty"`
3332
}
3433

3534
type Proxy struct {

0 commit comments

Comments
 (0)