Search in sources :

Example 1 with CrossOriginEmbedderPolicyHeaderWriter

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

the class HeadersConfigurer method crossOriginEmbedderPolicy.

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

Example 2 with CrossOriginEmbedderPolicyHeaderWriter

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

the class HeadersBeanDefinitionParser method parseCrossOriginEmbedderPolicy.

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

Aggregations

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