#What am I supposed to use if frameOptions() is deprecated

1 messages · Page 1 of 1 (latest)

ruby island
#

Beginner programmer working with Spring Security for the first time. Through research and chatGPT I landed on a solution that worked! (hurray) but I'm getting a warning that .frameOptions() is deprecated.

I can't just remove frameOptions() because it's allowing me to view my H2 console, what's the current way to allow them?

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http, AuthService authService) throws Exception {
        JwtTokenFilter jwtTokenFilter = new JwtTokenFilter(authService);

        http
                .csrf(csrf -> csrf.disable()) // Disable CSRF protection
                .addFilterBefore(jwtTokenFilter, UsernamePasswordAuthenticationFilter.class)
                .authorizeHttpRequests(authz -> authz
                        .requestMatchers("/h2-console/**").permitAll() // Permit H2 console access
                        .requestMatchers("/api/auth/**").permitAll() // Permit all requests to auth endpoints
                        .requestMatchers("/chat/**").permitAll() //
                        .requestMatchers("/api/users/**").permitAll()
                        .requestMatchers("/api/audio/**").permitAll()
                        .anyRequest().permitAll() // Require auth for all other requests
                )
                .headers(headers -> headers // Set headers to allow frame options for H2 console
                        .frameOptions().sameOrigin());

        return http.build();
    }
burnt stoneBOT
#

<@&1004656351647117403> please have a look, thanks.

earnest stone
#

If it is marked as Deprecated then it is very likely that solution to your problem can be found in Javadoc of that same method

elfin stratus
#

Try this

#

frameOptions(Customizer.withDefault())

ruby island
elfin stratus
hidden stream
#

it's withDefaults() as in the plural

elfin stratus
#

Good spot!

#

i didn't notice as i wrote it by hand

#

i assume it should be suggested by the ide and corrected as well :/

hidden stream
#

Indeed, I was about to say. It's an easy typo, and normally your IDE should offer autocompletion Paulus. (intellij => ctrl space or your OS equivalent)

ruby island
#

Is there a way to mark this solved? I'm new here

elfin stratus
#

ah looks good

#

just close this thread

#

with the following command

#

/help_thread close

ruby island
#

/help_thread close

elfin stratus
#

lmao