1

I am using spring boot '2.1.4.RELEASE'. After the implementation of spring security, it's blocking all my resources in the static folder.

Here is my spring security adapter code

package com.dbbl.payment.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;


@EnableWebSecurity
public class WebSecurityConfigAdapter extends WebSecurityConfigurerAdapter {
    @Autowired
    private Authenticator authenticator;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authenticator);
    }

    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable().authorizeRequests()
                .anyRequest().authenticated()
                .and()
                 .formLogin()
                .loginProcessingUrl("/login")
                .loginPage("/login").permitAll()
                 .and()
                .logout().logoutUrl("/logout")
                .logoutSuccessUrl("/login")
                .invalidateHttpSession(true)
                .and().httpBasic().disable();
    }
}

Here are the folder structure of my resources

enter image description here

1 Answers1

1

You can try move templates to static folder and try this:

@Override
public void configure(WebSecurity web) throws Exception {
    web
            .ignoring()
            .antMatchers("/assets/**", "/customs/**", "/templates/**");
}
Failed
  • 228
  • 2
  • 8
  • if I shift the templates folder to static than how controller will know the pages ? – Biswajit Debnath Apr 18 '19 at 06:50
  • Spring blocking templates too? If not you can not move these templates and just use .antMatchers("/assets/**", "/customs/**"); It should help for assets and customs in static folder. I hope. – Failed Apr 18 '19 at 07:03