Browse Source

Add Bookstore authentication handlers; define login processing and

fallback URLs; rename credential fields
Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
1455d582d1
1 changed files with 18 additions and 1 deletions
  1. +18
    -1
      bookstore/src/main/java/com/fjordtek/bookstore/config/WebSecurityConfig.java

+ 18
- 1
bookstore/src/main/java/com/fjordtek/bookstore/config/WebSecurityConfig.java View File

@ -13,6 +13,8 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.config.http.SessionCreationPolicy;
import com.fjordtek.bookstore.service.session.BookStoreAccessDeniedHandler;
import com.fjordtek.bookstore.service.session.BookStoreAuthenticationFailureHandler;
import com.fjordtek.bookstore.service.session.BookStoreAuthenticationSuccessHandler;
import com.fjordtek.bookstore.service.session.UserDetailServiceImpl;
/**
@ -43,9 +45,18 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authManagerBuilder)
throws Exception {
authManagerBuilder.userDetailsService(userDetailService);
authManagerBuilder.userDetailsService(userDetailService)
// .passwordEncoder(bCryptPasswordEncoder)
;
}
/*
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
*/
/*
* Have different HTTP security policies for:
*
@ -104,6 +115,12 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.authenticated()
.and()
.formLogin()
.usernameParameter("b_username")
.passwordParameter("b_password")
.successHandler(new BookStoreAuthenticationSuccessHandler())
.failureHandler(new BookStoreAuthenticationFailureHandler())
.loginProcessingUrl("/login")
.loginPage("/booklist")
.defaultSuccessUrl("/booklist")
.permitAll()
.and()


Loading…
Cancel
Save