How to make OAuth2Login applicable to only One endpoint in Spring Boot security?

40 views Asked by At
  @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
        http.authorizeHttpRequests
                (auth->auth
                        .requestMatchers(HttpMethod.POST,"/api/v1/**").permitAll()
                        .requestMatchers("/users").authenticated())
                .oauth2Login(Customizer.withDefaults());
        return http.build();



    }

Above code is applying Oauth2Login to every endpoint i want the OAuth2Login applied to only /users endpoint

is there a way to achieve this?

0

There are 0 answers