How to process a form login using Spring Security / Spring MVC

前端 未结 6 1458
暗喜
暗喜 2020-12-13 00:59

Simple question, I just need a pointer in the right direction:

I have a simple Spring MVC/Spring Security webapp. Initially I set up Spring Security so that the defa

6条回答
  •  佛祖请我去吃肉
    2020-12-13 01:49

    
      
      
    
    

    login-page is the login form URL login-processing-url is the url where login form is submitted. Spring will give a self call the authentication-manager mapped by you in security.xml file.

    Process

    1. You need to write a class that implements org.springframework.security.authentication.AuthenticationProvider with overriden method Authentication authenticate(Authentication authentication)
    2. Second class that extends org.springframework.security.core.userdetails.UserDetailsService with a overridden method loadUserByUsername(String username)
    3. The second class form where you can call your DAO and validate user with database fetching username and password.
    4. In Authentication authenticate(Authentication authentication) you will compare the password and return success failure your are done.

提交回复
热议问题