---
# System prepended metadata

title: PID-1132

---

In a Spring Boot application, you can configure security policies by using the `SecurityFilterChain` and `SecurityFilterChainBuilder` classes provided by Spring Security. To allow the `h-ua-form-factor` security policy, you can create a custom security filter chain to handle it.

Here's an example of how to allow the `h-ua-form-factor` security policy in a Spring Boot application:
1. Add the Spring Security dependency to your `pom.xml` or `build.gradle` file:

    For Maven:
    ```xml
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    ```
    For Gradle:
    ```gradle
    implementation 'org.springframework.boot:spring-boot-starter-security'
    ```
2. Create a configuration class to define your custom security filter chain. You can do this by extending `SecurityFilterChain` and overriding the `configure` method:
    ```java
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.web.SecurityFilterChain;

    @Configuration
    public class SecurityConfig {

        @Bean
        public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
            http
                .authorizeRequests(authorizeRequests ->
                    authorizeRequests
                        .antMatchers("/public/**").permitAll() // Define public endpoints
                        .antMatchers("/private/**").authenticated() // Define private endpoints
                )
                .httpBasic(withDefaults()); // Use HTTP Basic authentication

            // Add custom configuration for "h-ua-form-factor" security policy
            http
                .headers()
                    .contentSecurityPolicy("frame-ancestors 'self' https://trusted-site.com;")
                    .httpStrictTransportSecurity("max-age=31536000 ; includeSubDomains")
                    .and()
                .and()
                    .csrf().disable();

            return http.build();
        }
    }
    ```
    In this example, we create a custom security filter chain named `defaultSecurityFilterChain`. We define public and private endpoints using `authorizeRequests`. We also add custom security headers for the `h-ua-form-factor` policy using `.headers()`. Make sure to replace `/public/**` and `/private/**` with the actual URL patterns of your application.
3. Customize the security headers as needed for the `h-ua-form-factor` policy. In the example above, we set the `frame-ancestors` policy and enable HTTP Strict Transport Security (HSTS).
4. Customize the authentication method and other security configurations according to your application's requirements.
5. Run your Spring Boot application.

By following these steps, you can allow the h-ua-form-factor security policy in your Spring Boot application while also configuring other security settings as needed.