Skip to content

Instantly share code, notes, and snippets.

@levlaz
Created May 23, 2017 02:45
Show Gist options
  • Select an option

  • Save levlaz/4b1b44a92778ef5805033ab080e0ebd9 to your computer and use it in GitHub Desktop.

Select an option

Save levlaz/4b1b44a92778ef5805033ab080e0ebd9 to your computer and use it in GitHub Desktop.
Spring Webjars Security Config
package com.circleci.demojavaspring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
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.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/home", "/webjars/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment