headers

fun headers(headersConfiguration: HeadersDsl.() -> Unit)

Allows configuring response headers.

Example:

@Configuration
@EnableWebSecurity
class SecurityConfig {

@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http {
headers {
referrerPolicy {
policy = ReferrerPolicy.SAME_ORIGIN
}
}
}
return http.build()
}
}

Parameters

headersConfiguration

custom configurations to configure the response headers

See also