i was having problem getting spring security to process the login from the controller i have defined in a class namely
@RequestMapping(value="/login", method=RequestMethod.POST)
I did some googling and found that spring takes the default login processng page as /j_spring_security_check
So how can i make spring do the login processing from the controller i have defined.
I have this in my security.config file
@Override
protected void configure(HttpSecurity http) throws Exception {
try {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/static/**").permitAll()
.antMatchers("/settings/api/**").permitAll()
.antMatchers("/api/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login").permitAll()
.defaultSuccessUrl("/", true);
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("sadhiasdniaaaaaaaaaaaaaaaa:");
e.printStackTrace();
}
}
i want spring to use this controller to process the login but it isn't using it
@RequestMapping(value="/login", method=RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response) {
System.out.println("\n\n\n*******hello11111111111111******** " + request.getSession().getAttribute("userLoginStatus"));
String username = request.getParameter("username");
String password = request.getParameter("password");
boolean f = false;
f = customAuthenticationProvider.verifyUser(username,password,request);
if(f == false)
return "loginError";
else
return "index";
}
Make your controller a custom authentication provider and wire it up under the <authentication manager/> in your Spring security.xml file. See here for an example of such a configuration.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.