use of org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter in project spring-security by spring-projects.
the class HeadersConfigurer method referrerPolicy.
/**
* <p>
* Allows configuration for <a href="https://www.w3.org/TR/referrer-policy/">Referrer
* Policy</a>.
* </p>
*
* <p>
* Configuration is provided to the {@link ReferrerPolicyHeaderWriter} which support
* the writing of the header as detailed in the W3C Technical Report:
* </p>
* <ul>
* <li>Referrer-Policy</li>
* </ul>
* @param referrerPolicyCustomizer the {@link Customizer} to provide more options for
* the {@link ReferrerPolicyConfig}
* @return the {@link HeadersConfigurer} for additional customizations
* @see ReferrerPolicyHeaderWriter
*/
public HeadersConfigurer<H> referrerPolicy(Customizer<ReferrerPolicyConfig> referrerPolicyCustomizer) {
this.referrerPolicy.writer = new ReferrerPolicyHeaderWriter();
referrerPolicyCustomizer.customize(this.referrerPolicy);
return HeadersConfigurer.this;
}
use of org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter in project spring-security by spring-projects.
the class ReferrerPolicyHeaderWriterTests method writeHeadersReferrerPolicyCustom.
@Test
public void writeHeadersReferrerPolicyCustom() {
this.writer = new ReferrerPolicyHeaderWriter(ReferrerPolicy.SAME_ORIGIN);
this.writer.writeHeaders(this.request, this.response);
assertThat(this.response.getHeaderNames().size()).isEqualTo(1);
assertThat(this.response.getHeader("Referrer-Policy")).isEqualTo("same-origin");
}
Aggregations