I have a spring security config method. I want a particular method to be chained antMatchers("/**/**").permitAll()
only if a condition matches. something like this {dev == true ? .antMatchers("/**/**").permitAll(): ()->{}}
. Ofcourse it's not a valid syntax , what is the MOST CONSISE way of doing it . Looking for a menimum coding .
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.cors().disable()
.authorizeRequests()
{dev == true ? .antMatchers("/**/**").permitAll(): ()->{}} //dev only. NEVER enable on prod
.antMatchers("/", "/signup", "/static/**", "/api/sigin", "/api/signup", "**/favicon.ico").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/")
.loginProcessingUrl("/api/signin")
.successHandler(authSuccessHandler())
.failureHandler(authFailureHandler())
.permitAll()
.and()
.logout()
.permitAll();
}