Search in sources :

Example 1 with CrossOriginOpenerPolicyHeaderWriter

use of org.springframework.security.web.header.writers.CrossOriginOpenerPolicyHeaderWriter in project spring-security by spring-projects.

the class HeadersConfigurer method crossOriginOpenerPolicy.

/**
 * Allows configuration for <a href=
 * "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy">
 * Cross-Origin-Opener-Policy</a> header.
 * <p>
 * Calling this method automatically enables (includes) the
 * {@code Cross-Origin-Opener-Policy} header in the response using the supplied
 * policy.
 * <p>
 * <p>
 * Configuration is provided to the {@link CrossOriginOpenerPolicyHeaderWriter} which
 * responsible for writing the header.
 * </p>
 * @return the {@link HeadersConfigurer} for additional customizations
 * @since 5.7
 * @see CrossOriginOpenerPolicyHeaderWriter
 */
public HeadersConfigurer<H> crossOriginOpenerPolicy(Customizer<CrossOriginOpenerPolicyConfig> crossOriginOpenerPolicyCustomizer) {
    this.crossOriginOpenerPolicy.writer = new CrossOriginOpenerPolicyHeaderWriter();
    crossOriginOpenerPolicyCustomizer.customize(this.crossOriginOpenerPolicy);
    return HeadersConfigurer.this;
}
Also used : CrossOriginOpenerPolicyHeaderWriter(org.springframework.security.web.header.writers.CrossOriginOpenerPolicyHeaderWriter)

Example 2 with CrossOriginOpenerPolicyHeaderWriter

use of org.springframework.security.web.header.writers.CrossOriginOpenerPolicyHeaderWriter in project spring-security by spring-projects.

the class HeadersBeanDefinitionParser method parseCrossOriginOpenerPolicy.

private void parseCrossOriginOpenerPolicy(boolean elementDisabled, Element element) {
    if (elementDisabled || element == null) {
        return;
    }
    CrossOriginOpenerPolicyHeaderWriter writer = new CrossOriginOpenerPolicyHeaderWriter();
    Element crossOriginOpenerPolicyElement = DomUtils.getChildElementByTagName(element, CROSS_ORIGIN_OPENER_POLICY_ELEMENT);
    if (crossOriginOpenerPolicyElement != null) {
        addCrossOriginOpenerPolicy(crossOriginOpenerPolicyElement, writer);
    }
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CrossOriginOpenerPolicyHeaderWriter.class, () -> writer);
    this.headerWriters.add(builder.getBeanDefinition());
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) CrossOriginOpenerPolicyHeaderWriter(org.springframework.security.web.header.writers.CrossOriginOpenerPolicyHeaderWriter) BeanMetadataElement(org.springframework.beans.BeanMetadataElement) Element(org.w3c.dom.Element)

Aggregations

CrossOriginOpenerPolicyHeaderWriter (org.springframework.security.web.header.writers.CrossOriginOpenerPolicyHeaderWriter)2 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1 Element (org.w3c.dom.Element)1