2
\$\begingroup\$

I'm trying to configure security exceptions to all JavaScript/CSS of my pages.

I need to login to access the JSP files, except the login page, but all pages needs your resources so the folders must be access-free.

.csrf().disable()
.authorizeRequests()
.antMatchers("/login*").anonymous()
.antMatchers("/bower_components/**").permitAll()
.antMatchers("/custom/**").permitAll()
.antMatchers("/plugins/**").permitAll()
.antMatchers("/dist/**").permitAll()
.anyRequest().authenticated()
.and()

.formLogin()
.loginPage("/loginPage")
.defaultSuccessUrl("/home", true)
.failureUrl("/loginPage?error=true")
.loginProcessingUrl("/login")
.usernameParameter("username")
.passwordParameter("password")
.and()

.logout()
.logoutSuccessUrl("/loginPage")
.invalidateHttpSession(true); 
\$\endgroup\$
1
  • \$\begingroup\$ Hi Jamal. The text has lost its meaning / purpose when you removed the the code seems ugly part of original question. I need to know if the code in question is as elegant as possible and without the original text the users may not know what I mean. Someone may flag as obscure... \$\endgroup\$
    – Magno C
    May 3, 2018 at 1:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.