Zugriff auf statische Inhalte im gesicherten Spring-Boot-Anwendung

Ich habe einen standalone-Spring-Boot-Anwendung mit Vorlagen in /src/main/resources/templates und statischen Inhalt in /src/main/resources/static. Ich möchte die statischen Inhalte zugänglich sein, bevor die Authentifizierung, also die CSS-Lasten auf die login-Seite als auch. Jetzt ist es nur lädt nach der Authentifizierung. Meine security-Konfiguration sieht so aus:

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private static final Logger logger = Logger.getLogger(SecurityConfig.class);

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) {
        try {
            auth.inMemoryAuthentication()
            ...
        } catch (Exception e) {
            logger.error(e);
        }
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .csrf().disable()
            .formLogin()
                .defaultSuccessUrl("/projects", true)
                .loginPage("/login")
                .permitAll()
                .and()
            .logout()
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET"))
                .permitAll()
                .and()
            .authorizeRequests()
                .antMatchers("/static/**").permitAll()
                .anyRequest().authenticated();
    }

}
InformationsquelleAutor user3170702 | 2014-04-02
Schreibe einen Kommentar