ServerContentSecurityPolicyDsl

A Kotlin DSL to configure the ServerHttpSecurity Content-Security-Policy header using idiomatic Kotlin code.

Author

Eleftheria Stein

Ziqin Wang

Since

5.4

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
var exchangeMatcher: ServerWebExchangeMatcher?

The ServerWebExchangeMatcher to use for determining when CSP should be applied. The default is to enable CSP in every response if ServerHeadersDsl.contentSecurityPolicy is configured.

Link copied to clipboard

The name of the request attribute for the generated nonce. Views can read this attribute to render the nonce in HTML.

Link copied to clipboard

The security policy directive(s) to be used in the response header. The policyDirectives may contain {nonce} as placeholders for a generated secure random nonce, e.g., script-src 'self' 'nonce-{nonce}'.

Link copied to clipboard

Includes the Content-Security-Policy-Report-Only header in the response.

Functions

Link copied to clipboard
fun exchangeMatchers(vararg pathPatterns: String)

Specify the matching path patterns for determining when CSP should be applied. The default is to enable CSP in every response if ServerHeadersDsl.contentSecurityPolicy is configured.