Created
February 17, 2014 15:10
-
-
Save robhinds/9052337 to your computer and use it in GitHub Desktop.
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
| @Configuration | |
| @EnableWebSecurity | |
| public class SecurityConfig extends WebSecurityConfigurerAdapter { | |
| @Autowired private UserDetailsServiceImpl userDetailsServiceImpl; | |
| @Override | |
| protected void configure(HttpSecurity http) throws Exception { | |
| http | |
| .csrf() | |
| .disable() | |
| .authorizeRequests() | |
| .antMatchers("/resources/**").permitAll() | |
| .antMatchers("/dashboard").permitAll() | |
| .antMatchers("/sign-up").permitAll() | |
| .antMatchers("/api/contacts/**").authenticated() | |
| .anyRequest().authenticated() | |
| .and() | |
| .formLogin() | |
| .loginPage("/") | |
| .loginProcessingUrl("/loginprocess") | |
| .failureUrl("/?loginFailure=true") | |
| .permitAll(); | |
| } | |
| @Override | |
| protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception { | |
| auth | |
| .userDetailsService(userDetailsServiceImpl) | |
| .passwordEncoder(bCryptPasswordEncoder()); | |
| } | |
| @Bean | |
| public BCryptPasswordEncoder bCryptPasswordEncoder(){ | |
| return new BCryptPasswordEncoder(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment