Created
March 25, 2014 15:41
-
-
Save robhinds/9764515 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 | |
| @Order(2) | |
| public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |
| @Autowired private UserDetailsServiceImpl userDetailsServiceImpl; | |
| @Autowired private CustomTokenBasedRememberMeService tokenBasedRememberMeService; | |
| @Autowired private RememberMeAuthenticationProvider rememberMeAuthenticationProvider; | |
| @Override protected void configure(HttpSecurity http) throws Exception { | |
| http | |
| .csrf() | |
| .disable() | |
| .authorizeRequests() | |
| .antMatchers("/resources/**").permitAll() | |
| .antMatchers("/sign-up").permitAll() | |
| .antMatchers("/sign-in").permitAll() | |
| .anyRequest().authenticated() | |
| .and() | |
| .formLogin() | |
| .loginPage("/") | |
| .loginProcessingUrl("/loginprocess") | |
| .failureUrl("/mobile/app/sign-in?loginFailure=true") | |
| .permitAll().and() | |
| .rememberMe().rememberMeServices(tokenBasedRememberMeService); | |
| } | |
| @Override protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception { | |
| auth | |
| .userDetailsService(userDetailsServiceImpl) | |
| .passwordEncoder(bCryptPasswordEncoder()); | |
| auth.authenticationProvider(rememberMeAuthenticationProvider); | |
| } | |
| @Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception { | |
| return super.authenticationManagerBean(); | |
| } | |
| @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