Skip to content

Commit 17b4c9c

Browse files
authored
Merge pull request #88802 from openshift-cherrypick-robot/cherry-pick-88593-to-enterprise-4.18
[enterprise-4.18] OSDOCS#13072:Adds Content Security Policy for web console
2 parents 50e1229 + b5f9bf2 commit 17b4c9c

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

_topic_maps/_topic_map.yml

+2
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,8 @@ Topics:
886886
File: dynamic-plugins-get-started
887887
- Name: Deploy your plugin on a cluster
888888
File: deploy-plugin-cluster
889+
- Name: Content Security Policy
890+
File: content-security-policy
889891
- Name: Dynamic plugin example
890892
File: dynamic-plugin-example
891893
- Name: Dynamic plugin reference

modules/csp-overview.adoc

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * web_console/dynamic-plugin/content-security-policy.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="content-security-policy-overview_{context}"]
7+
= Content Security Policy (CSP) overview
8+
9+
A Content Security Policy (CSP) is delivered to the browser in the `Content-Security-Policy-Report-Only` response header. The policy is specified as a series of directives and values. Each directive type serves a different purpose, and each directive can have a list of values representing allowed sources.
10+
11+
[id="content-security-policy-key-features_{context}"]
12+
== Key features of `contentSecurityPolicy`
13+
14+
[discrete]
15+
=== Directive Types
16+
17+
The supported directive types include `DefaultSrc`, `ScriptSrc`, `StyleSrc`, `ImgSrc`, and `FontSrc`. These directives allow you to specify valid sources for loading different types of content for your plugin. Each directive type serves a different purpose. For example, `ScriptSrc` defines valid JavaScript sources, while `ImgSrc` controls where images can be loaded from.
18+
19+
//backporting the ConnectSrc directive, but that is tbd - openshift/console#14701 and https://github.com/openshift/api/pull/2164
20+
21+
22+
[discrete]
23+
=== Values
24+
25+
Each directive can have a list of values representing allowed sources. For example, `ScriptSrc` can specify multiple external scripts. These values are restricted to 1024 characters and cannot include whitespace, commas, or semicolons. Additionally, single-quoted strings and wildcard characters (`*`) are disallowed.
26+
27+
[discrete]
28+
=== Unified Policy
29+
30+
The {product-title} web console aggregates the CSP directives across all enabled `ConsolePlugin` custom resources (CRs) and merges them with its own default policy. The combined policy is then applied with the `Content-Security-Policy-Report-Only` HTTP response header.
31+
32+
[discrete]
33+
=== Validation Rules
34+
* Each directive can have up to 16 unique values.
35+
* The total size of all values across directives must not exceed 8192 bytes (8KB).
36+
* Each value must be unique, and additional validation rules are in place to ensure no quotes, spaces, commas, or wildcard symbols are used.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="content-security-policy_{context}"]
3+
= Content Security Policy (CSP)
4+
include::_attributes/common-attributes.adoc[]
5+
:context: content-security-policy
6+
7+
toc::[]
8+
9+
You can specify Content Security Policy (CSP) directives for your dynamic plugin using the `contentSecurityPolicy` field in the `ConsolePluginSpec` file. This field helps mitigate potential security risks by specifying which sources are allowed for fetching content like scripts, styles, images, and fonts. For dynamic plugins that require loading resources from external sources, defining custom CSP rules ensures secure integration into the {product-title} console.
10+
11+
[IMPORTANT]
12+
====
13+
The console currently uses the `Content-Security-Policy-Report-Only` response header, so the browser will only warn about CSP violations in the web console and enforcement of CSP policies will be limited. CSP violations will be logged in the browser console, but the associated CSP directives will not be enforced. This feature is behind a `feature-gate`, so you will need to manually enable it.
14+
15+
For more information, see xref:../../nodes/clusters/nodes-cluster-enabling-features.adoc#nodes-cluster-enabling-features-console_nodes-cluster-enabling[Enabling feature sets using the web console].
16+
====
17+
18+
include::modules/csp-overview.adoc[leveloffset=+1]
19+
20+
[role="_additional-resources"]
21+
[id="content-security-policy_additional-resources"]
22+
== Additional resources
23+
24+
* link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy[Content Security Policy (CSP)]
25+

web_console/dynamic-plugin/dynamic-plugin-example.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ toc::[]
88

99
Before working through the example, verify that the plugin is working by following the steps in xref:../../web_console/dynamic-plugin/dynamic-plugins-get-started.adoc#dynamic-plugin-development_dynamic-plugins-get-started[Dynamic plugin development]
1010

11-
include::modules/adding-tab-pods-page.adoc[leveloffset=+1]
11+
include::modules/adding-tab-pods-page.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)