Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EnableWebMvcSecurity
- @Configuration
- public class SecurityConfig extends WebSecurityConfigurerAdapter
- {
- @Inject
- private UserDetailsServiceImpl userDetailsService;
- @Override
- public void configure(WebSecurity webSecurity) throws Exception {
- webSecurity.ignoring().antMatchers("/static/**");
- }
- @Override
- protected void configure(HttpSecurity httpSecurity) throws Exception {
- httpSecurity
- .formLogin()
- .loginPage("/signin")
- .loginProcessingUrl("/signin/authenticate")
- .failureUrl("/signin?error=bad_credentials")
- .and()
- .logout()
- .deleteCookies("JSESSIONID")
- .logoutUrl("/signout")
- .logoutSuccessUrl("/")
- .and()
- .authorizeRequests()
- .antMatchers(
- "/",
- "/signin/**",
- "/signup/**",
- "/about",
- "/privacyPolicy",
- "/termsConditions",
- "/addYourChurch",
- "/search",
- "/contact",
- "/church-profile/**"
- ).permitAll()
- .antMatchers("/**").hasRole("USER")
- .and()
- .apply(new SpringSocialConfigurer());
- }
- @Override
- protected void configure(AuthenticationManagerBuilder authenticationManager) throws Exception {
- authenticationManager.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
- }
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement