ContentSecurityPolicyDsl

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

Author

Eleftheria Stein

Ziqin Wang

Since

5.3

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The name of the servlet 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.

Link copied to clipboard
var requestMatcher: RequestMatcher?

The RequestMatcher to use for determining when CSP should be applied. The default is to enable CSP in every response if org.springframework.security.config.annotation.web.HeadersDsl.contentSecurityPolicy is configured.

Functions

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

Specify the matching path patterns for determining when CSP should be applied. The default is to write CSP header in every response if org.springframework.security.config.annotation.web.HeadersDsl.contentSecurityPolicy is configured.