Search in sources :

Example 1 with CrossOriginResourcePolicyHeaderWriter

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

the class HeadersConfigurer method crossOriginResourcePolicy.

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

Example 2 with CrossOriginResourcePolicyHeaderWriter

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

the class HeadersBeanDefinitionParser method parseCrossOriginResourcePolicy.

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

Aggregations

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