Skip to content

Commit a8fa8f9

Browse files
feat: tech writer review
1 parent dcd7475 commit a8fa8f9

File tree

3 files changed

+51
-43
lines changed

3 files changed

+51
-43
lines changed

content/en/docs/deployment/mendix-cloud-deploy/environments-details.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ document.cookie = "originURI=/login.html" + (window.location.protocol === "https
321321

322322
#### Content Security Policy {#csp}
323323

324-
A Content Security Policy informs the client (browser) where your page loads resources from. Setting this can make your app more secure by declaring trusted sources for your resources. For more information, see the W3C recommendation [Content Security Policy Level 2](https://www.w3.org/TR/CSP2/).
324+
A Content Security Policy (CSP) informs the client (browser) where your page loads resources from. Setting this can make your app more secure by declaring trusted sources for your resources. For more information, see the W3C recommendation [Content Security Policy Level 2](https://www.w3.org/TR/CSP2/).
325325

326326
{{% alert color="info" %}}
327-
For full CSP support including nonce-based CSP, use the [Headers](/refguide/configuration/#headers) custom runtime setting instead of the HTTP Headers UI. The custom runtime setting method is recommended as it provides more comprehensive CSP capabilities. For detailed implementation guidance, see [Content Security Policy](/howto/security/csp/).
327+
For complete CSP support, including nonce-based CSP, use the [Headers](/refguide/configuration/#headers) custom runtime setting instead of the HTTP Headers UI. For detailed implementation instructions, see [Content Security Policy](/howto/security/csp/).
328328
{{% /alert %}}
329329

330330
The process for setting a full content security policy depends on what your app does. However, a starting point that declares the content security policy that works with a basic Mendix app is given below:

content/en/docs/howto/security/csp.md

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -176,38 +176,38 @@ After you finish testing locally, remember to remove the line of code in the `he
176176
177177
## CSP Support in Java Request Handlers
178178
179-
If you are developing Marketplace modules or custom Java actions that include request handlers, you may need to implement CSP support to ensure compatibility with strict CSP policies. This includes support for CSP Level 2+ features like nonces for inline scripts and styles.
179+
When developing Marketplace modules or custom Java actions that include request handlers, you may need to implement CSP support to ensure compatibility with strict CSP policies. This includes support for CSP Level 2+ features such as nonces for inline scripts and styles.
180180
181181
{{% alert color="info" %}}
182182
CSP support is only relevant for request handlers that serve static content such as HTML pages, not for API endpoints that return JSON or other data formats.
183183
{{% /alert %}}
184184
185-
This section describes how to properly handle CSP headers in your Java request handlers when serving HTML content.
185+
This section describes how to properly handle CSP headers in Java request handlers when serving HTML content.
186186
187187
### Available CSP APIs
188188
189-
Mendix provides two APIs for CSP support in Java request handlers:
189+
Mendix provides two APIs to support CSP in Java request handlers:
190190
191191
#### IMxRuntimeResponse Methods
192192
193-
The `IMxRuntimeResponse` interface provides basic CSP methods:
193+
The `IMxRuntimeResponse` interface provides these basic CSP methods:
194194
195-
* `addContentSecurityPolicyHeader()` - Adds the Content-Security-Policy header as configured in the application
196-
* `getNonce()` - Returns a uniquely generated secure nonce for the response that can be used in CSP directives
197-
* `addHeader(String key, String value)` - Adds a custom header to the response
195+
* `addContentSecurityPolicyHeader()` Adds the Content-Security-Policy header as configured in the application
196+
* `getNonce()` Returns a secure, uniquely generated nonce for the response that you can use in CSP directives
197+
* `addHeader(String key, String value)` Adds a custom header to the response
198198
199199
#### CspHelper Interface (Recommended)
200200
201-
The `CspHelper` interface provides additional utility methods for more sophisticated CSP handling:
201+
The `CspHelper` interface provides additional utility methods for more advanced CSP handling:
202202
203-
* `getTemplate()` - Get the template used for the Content-Security-Policy header value
204-
* `getNonce(IMxRuntimeResponse response)` - Get the generated nonce of the current HTTP response
205-
* `hasNonce(IMxRuntimeResponse response)` - Returns true if the configured CSP template contains the `{{ NONCE }}` placeholder, for example: `Content-Security-Policy: script-src 'nonce-{{ NONCE }}'`
206-
* `addHeader(IMxRuntimeResponse response)` - Add Content-Security-Policy header to the response using the configured template
203+
* `getTemplate()` – Gets the template used for the Content-Security-Policy header value
204+
* `getNonce(IMxRuntimeResponse response)` – Gets the generated nonce of the current HTTP response
205+
* `hasNonce(IMxRuntimeResponse response)` Returns true if the configured CSP template contains the `{{ NONCE }}` placeholder. For example: `Content-Security-Policy: script-src 'nonce-{{ NONCE }}'`
206+
* `addHeader(IMxRuntimeResponse response)` – Adds Content-Security-Policy header to the response using the configured template
207207
208208
### Example Implementation
209209
210-
Here's how to implement CSP support in a Java request handler using the `CspHelper`:
210+
Here's how to implement CSP support in a Java request handler using the `CspHelper` interface:
211211

212212
```java
213213
package your.module.requesthandlers;
@@ -247,24 +247,24 @@ public class YourRequestHandler extends RequestHandler {
247247
html.append("<!DOCTYPE html>\n");
248248
html.append("<html>\n");
249249
html.append("<head>\n");
250-
html.append(" <title>Your Module</title>\n");
250+
html.append("<title>Your Module</title>\n");
251251
252252
// Only use nonce if it's configured in the CSP template
253253
if (Core.csp().hasNonce(response)) {
254254
String nonce = Core.csp().getNonce(response);
255-
html.append(" <script nonce=\"").append(nonce).append("\">\n");
256-
html.append(" // Your inline JavaScript here\n");
257-
html.append(" console.log('This script is CSP-compliant with nonce');\n");
258-
html.append(" </script>\n");
255+
html.append("<script nonce=\"").append(nonce).append("\">\n");
256+
html.append("// Your inline JavaScript here\n");
257+
html.append("console.log('This script is CSP-compliant with nonce');\n");
258+
html.append("</script>\n");
259259
} else {
260260
// Alternative approach when nonce is not configured
261-
html.append(" <script src=\"/path/to/external/script.js\"></script>\n");
261+
html.append("<script src=\"/path/to/external/script.js\"></script>\n");
262262
}
263263
264264
html.append("</head>\n");
265265
html.append("<body>\n");
266-
html.append(" <h1>Your Module Content</h1>\n");
267-
html.append(" <!-- Your content here -->\n");
266+
html.append("<h1>Your Module Content</h1>\n");
267+
html.append("<!-- Your content here -->\n");
268268
html.append("</body>\n");
269269
html.append("</html>\n");
270270
@@ -277,45 +277,53 @@ public class YourRequestHandler extends RequestHandler {
277277

278278
When implementing CSP support in your request handlers, follow these best practices:
279279

280-
1. **Use CspHelper for conditional nonce support** - Always check if nonce is configured before using it:
280+
* **Use `CspHelper` for conditional nonce support** – Always check if nonce is configured before using it:
281+
281282
```java
282283
if (Core.csp().hasNonce(response)) {
283-
String nonce = Core.csp().getNonce(response);
284-
// Use nonce for inline content
284+
String nonce = Core.csp().getNonce(response);
285+
// Use nonce for inline content
285286
} else {
286-
// Use external resources or alternative approach
287+
// Use external resources or alternative approach
287288
}
288289
```
289290

290-
2. **Always add CSP headers** - Use `Core.csp().addHeader(response)` to ensure your module respects the application's CSP configuration when serving HTML content.
291+
* **Always add CSP headers** Use `Core.csp().addHeader(response)` to ensure your module respects the application's CSP configuration when serving HTML content.
291292
292-
3. **CSP is only needed for HTML content** - Only implement CSP support in request handlers that serve HTML pages. API endpoints returning JSON, XML, or other data formats do not need CSP headers.
293+
* **CSP is only needed for HTML content** Only implement CSP support in request handlers that serve HTML pages. API endpoints returning JSON, XML, or other data formats do not need CSP headers.
293294
294-
4. **Avoid inline scripts and styles when possible** - Prefer external files that can be loaded via `'self'` directive.
295+
* **Avoid inline scripts and styles when possible** – Use external files that can be loaded via `'self'` directive.
295296
296-
5. **Test with strict CSP** - Test your request handlers with `default-src: 'self'` to ensure they work with the strictest CSP settings.
297+
* **Test with strict CSP** Test your request handlers with `default-src: 'self'` to ensure they work with the strictest CSP settings.
297298
298299
### Common CSP Issues in Request Handlers
299300
300301
When working with CSP in request handlers, you may encounter these common issues:
301302
302303
#### Base64 Images
303-
If your request handler generates inline Base64 images, these will be blocked by strict CSP. Consider these alternatives:
304-
- Serving images as separate endpoints
305-
- Using external image hosting
306-
- Adding `data:` to `img-src` directive (less secure)
304+
305+
Strict CSP blocks inline Base64 images that your request handler generates. Consider these alternatives:
306+
307+
* Serve images as separate endpoints
308+
* Use external image hosting
309+
* Add `data:` to `img-src` directive (less secure)
307310
308311
#### Dynamic Script Generation
312+
309313
Avoid generating `<script>` tags dynamically without nonces. Instead:
310-
- Use the provided nonce for any inline scripts
311-
- Move logic to external JavaScript files
312-
- Use data attributes and external scripts to handle dynamic behavior
314+
315+
* Use the provided nonce for any inline scripts
316+
* Move logic to external JavaScript files
317+
* Use data attributes and external scripts to handle dynamic behavior
313318
314319
#### Third-party Resources
315-
If your module loads external resources, ensure they're allowed by the CSP or provide configuration options for developers to whitelist them.
320+
321+
If your module loads external resources, make sure they are allowed by the CSP or provide configuration options for developers to whitelist them.
316322
317323
#### Error Handling
324+
318325
When CSP violations occur, implement proper error handling:
326+
319327
```java
320328
// Log CSP-related errors for debugging
321329
if (Core.csp().hasNonce(response)) {
@@ -327,7 +335,7 @@ if (Core.csp().hasNonce(response)) {
327335
328336
## Enabling the Header in the Cloud
329337
330-
There are two ways to enable the header in the Cloud:
338+
There are two ways to enable the header in the cloud:
331339
332-
1. Using the [Headers](/refguide/configuration/#headers) custom runtime setting (Recommended ✅). Use this if you need nonce-based CSP support. You can configure this in the Developer Portal under [Custom Runtime Settings](/developerportal/deploy/environments-details/#custom-runtime-settings).
333-
2. Using the [HTTP Headers](/developerportal/deploy/environments-details/#http-headers) UI in the *Environment Details* section. Can be used for basic CSP support.
340+
1. **[Headers](/refguide/configuration/#headers) custom runtime setting (Recommended)**: Use this if you need nonce-based CSP support. Configure this in the Developer Portal under [Custom Runtime Settings](/developerportal/deploy/environments-details/#custom-runtime-settings).
341+
2. **HTTP Headers UI:** This method works for basic CSP support. For more details, refer to the [HTTP Headers](/developerportal/deploy/environments-details/#http-headers) section of *Environment Details*.

content/en/docs/refguide/runtime/custom-settings/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The following custom settings can be configured:
7272
| <a id="ScheduledEventExecution" href="#ScheduledEventExecution">ScheduledEventExecution</a> | Specify which scheduled events should be executed. Choices are `ALL`, `NONE`, or `SPECIFIED`. In the case of `SPECIFIED`, enumerate the scheduled events using the `MyScheduledEvents` configuration option described below. {{% alert color="warning" %}}This setting cannot be configured when running locally. To enable and disable scheduled events when running locally, please use the 'Enabled' setting on the [Scheduled Events execution properties](/refguide/scheduled-events/) in Studio Pro.{{% /alert %}} | NONE |
7373
| <a id="SessionKeepAliveUpdatesInterval" href="#SessionKeepAliveUpdatesInterval">SessionKeepAliveUpdatesInterval</a> | Defines how often a runtime writes session LastActive dates in its memory back to the database. | one sixth of the value configured for the `SessionTimeout` setting; if the `SessionTimeout` is not set, this value defaults to 100000 (100 seconds) |
7474
| <a id="SessionTimeout" href="#SessionTimeout">SessionTimeout</a> | Defines after how much time a session becomes invalid (in milliseconds). After that timeout, a session becomes eligible for removal. The session will not be destroyed until the next time a scheduled task runs to clean up the active sessions. <br> {{% alert color="warning" %}} Logging out can also be triggered by a query to the runtime after the session becomes eligible for removal. Navigating between pages is not enough to trigger a query to the runtime. To force a query to the runtime, use microflows. For example, create a microflow that shows the Home page, then configure your app's navigation to call this microflow rather than relying on the navigation to directly show the page itself. This will ensure the runtime is queried and the user is logged out of their session. {{% /alert %}} | 600000 (10 minutes) |
75-
| <a id="Headers" href="#Headers">Headers</a> | A JSON object containing custom headers (key-value). For example, can be used to define a `Content-Security-Policy`, e.g.: `{ "Content-Security-Policy": "script-src 'nonce-{{ NONCE }}'" }`. | `{}` |
75+
| <a id="Headers" href="#Headers">Headers</a> | A JSON object containing custom headers as key/value pairs, and can be used to define a `Content-Security-Policy`. For example, `{ "Content-Security-Policy": "script-src 'nonce-{{ NONCE }}'" }`. | `{}` |
7676
| <a id="TaskQueueShutdownGracePeriod" href="#TaskQueueShutdownGracePeriod">TaskQueue.<wbr>ShutdownGracePeriod</a> | Time in ms to wait for task in a task queue to finish when shutting down. | 10000 (10 seconds) |
7777
| <a id="TempPath" href="#TempPath">TempPath</a> | The location of the temporary files. | [deployment folder]\data\tmp |
7878
| <a id="TrackWebServiceUserLastLogin" href="#TrackWebServiceUserLastLogin">TrackWebServiceUserLastLogin</a> | Defines whether to update a user's `LastLogin` field on each login when logging in to a published REST, OData, or web service. When this happens a database update query has to be sent and this can have performance consequences on heavy load systems. When this setting is set to false, no database interaction is necessary. | true |

0 commit comments

Comments
 (0)