Created
May 23, 2017 02:45
-
-
Save levlaz/4b1b44a92778ef5805033ab080e0ebd9 to your computer and use it in GitHub Desktop.
Spring Webjars Security Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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