@@ -57,8 +57,8 @@ type ConsolePluginSpec struct {
5757 // CSP violation reports can be viewed in browser's console during development and testing
5858 // of the plugin in the OpenShift web console.
5959 // Available directives are default-src, script-src, img-src, style-src and font-src.
60- // Each of the available CSP directive may be defined only once in the list.
61- // By default the console server adds the value 'self'to all the various 'src' directives.
60+ // Each of the available directives may be defined only once in the list.
61+ // By default the console server adds the value 'self 'to all the various '*- src' directives.
6262 // For more information about the CSP directives, see:
6363 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6464 //
@@ -68,67 +68,68 @@ type ConsolePluginSpec struct {
6868 //
6969 // Example:
7070 // ConsolePlugin A directives:
71- // script-src: https://script1.com/ https://script2.com/
71+ // script-src: https://script1.com/, https://script2.com/
7272 // font-src: https://font1.com/
7373 //
7474 // ConsolePlugin B directives:
75- // script-src: https://script2.com/ https://script3.com/
75+ // script-src: https://script2.com/, https://script3.com/
7676 // font-src: https://font2.com/
7777 // img-src: https://img1.com/
7878 //
79+ // Unified set of CSP directives, passed to the OpenShift web console server:
80+ // script-src: https://script1.com/, https://script2.com/, https://script3.com/
81+ // font-src: https://font1.com/, https://font2.com/
82+ // img-src: https://img1.com/
83+ //
7984 // OpenShift web console server CSP response header:
80- // script-src: self https://script1.com/ https://script2.com/ https://script3.com/
81- // font-src: self https://font1.com/ https://font2.com/
82- // img-src: self https://img1.com/
85+ // Content-Security-Policy: default-src 'self'; base-uri 'self'; script-src 'self' https://script1.com/ https://script2.com/ https://script3.com/; font-src 'self' https://font1.com/ https://font2.com/; img-src 'self' https://img1.com/; style-src 'self'; frame-src 'none'; object-src 'none'
8386 //
8487 // +kubebuilder:validation:MinItems=1
8588 // +kubebuilder:validation:MaxItems=5
8689 // +listType=map
87- // +listMapKey=name
90+ // +listMapKey=directive
8891 // +optional
89- ContentSecurityPolicy []ConsolePluginCSP `json:"contentSecurityPolicy,omitempty "`
92+ ContentSecurityPolicy []ConsolePluginCSP `json:"contentSecurityPolicy"`
9093}
9194
9295// DirectiveType is an enumeration of OpenShift web console supported CSP directives.
9396// LoadType is an enumeration of i18n loading types.
94- // +kubebuilder:validation:Enum:=default-src;script-src;img-src;style-src;font-src
97+ // +kubebuilder:validation:Enum:="DefaultSrc";"ScriptSrc";"ImgSrc";"StyleSrc";"FontSrc"
9598type DirectiveType string
9699
97100const (
98- // default-src directive serves as a fallback for the other CSP fetch directives.
101+ // DefaultSrc directive serves as a fallback for the other CSP fetch directives.
99102 // For more information about the default-src directive, see:
100103 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src
101- DefaultSrc DirectiveType = "default-src "
102- // script-src directive specifies valid sources for JavaScript.
104+ DefaultSrc DirectiveType = "DefaultSrc "
105+ // ScriptSrc directive specifies valid sources for JavaScript.
103106 // For more information about the script-src directive, see:
104107 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
105- ScriptSrc DirectiveType = "script-src "
106- // img-src directive specifies a valid sources of images and favicons.
108+ ScriptSrc DirectiveType = "ScriptSrc "
109+ // ImgSrc directive specifies a valid sources of images and favicons.
107110 // For more information about the img-src directive, see:
108111 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/img-src
109- ImgSrc DirectiveType = "img-src "
110- // style-src directive specifies valid sources for stylesheets.
112+ ImgSrc DirectiveType = "ImgSrc "
113+ // StyleSrc directive specifies valid sources for stylesheets.
111114 // For more information about the style-src directive, see:
112115 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
113- StyleSrc DirectiveType = "style-src "
114- // font-src directive specifies valid sources for fonts loaded using @font-face.
116+ StyleSrc DirectiveType = "StyleSrc "
117+ // FontSrc directive specifies valid sources for fonts loaded using @font-face.
115118 // For more information about the font-src directive, see:
116119 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src
117- FontSrc DirectiveType = "font-src "
120+ FontSrc DirectiveType = "FontSrc "
118121)
119122
120123// ConsolePluginCSP holds configuration for a specific CSP directive
121124type ConsolePluginCSP struct {
122125 // directive specifies which Content-Security-Policy directive to configure.
123- // Available directive types are default-src, script-src, img-src, style-src and font-src.
124- // +kubebuilder:validation:Enum:="default-src";"script-src";"img-src";"style-src";"font-src"
126+ // Available directive types are DefaultSrc, ScriptSrc, ImgSrc, StyleSrc and FontSrc.
125127 // +kubebuilder:validation:Required
126128 Directive DirectiveType `json:"directive"`
127- // values defines an array of additional values to append to the console
128- // defaults for this directive.
129+ // values defines an array of values to append to the console defaults for this directive.
129130 // Each ConsolePlugin may define their own directives with their values.
130131 // These will be set by the OpenShift web console's backend, as part of
131- // its CSP header.
132+ // its Content Security Policy header.
132133 // +kubebuilder:validation:Required
133134 // +kubebuilder:validation:MinItems=1
134135 Values []string `json:"values"`
0 commit comments