Last active
January 22, 2023 14:22
-
-
Save luismoramedina/27f5647fc2067284d3fa9c09f22438fe to your computer and use it in GitHub Desktop.
Spring security - Disable security for OPTIONS (CORS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class WebSecurity extends WebSecurityConfigurerAdapter { | |
@Override | |
protected void configure(HttpSecurity http) throws Exception { | |
http | |
.csrf().disable() | |
.authorizeRequests() | |
.antMatchers(HttpMethod.OPTIONS, "**").permitAll()//allow CORS option calls | |
.anyRequest().authenticated(); | |
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still its not working..(antMatchers deprecated ...so used requestMatchers)