Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security loginPage Vs loginProcessingURL

what is the difference between loginPage vs loginProcessingURL. .formLogin().loginPage("/login").usernameParameter("phone-number").passwordParameter("password")

Seems to be loginProcessingURL is like post method once user submits the data in the login page but when I remove also it is working fine. What is the significance of loginProcessingURL and how does it differ from loginPage?

like image 686
Ashwini Jha Avatar asked Nov 04 '18 12:11

Ashwini Jha


People also ask

What is loginProcessingUrl in Spring Security?

loginProcessingUrl(): It specifies the URL using which username and password is validated. usernameParameter(): It specifies the field name to enter user name which is used by spring security to validate. If not specified then default is username.

Is WebSecurityConfigurerAdapter deprecated?

From Spring Boot 2.7, WebSecurityConfigurerAdapter is deprecated.

What is an alternative of Spring Security?

Django, OAuth2, Keycloak, Auth0, and Amazon Cognito are the most popular alternatives and competitors to Spring Security.


1 Answers

The line loginPage("/login") instructs Spring Security

  • when authentication is required, redirect the browser to /login
  • we are in charge of rendering the login page when /login is requested
  • when authentication attempt fails, redirect the browser to /login?error (since we have not specified otherwise)
  • we are in charge of rendering a failure page when /login?error is requested
  • when we successfully logout, redirect the browser to /login?logout (since we have not specified otherwise)
  • we are in charge of rendering a logout confirmation page when /login?logout is requested

AND

.loginProcessingUrl("/login/process")

tells Spring Security to process the submitted credentials when sent the specified path and, by default, redirect user back to the page user came from. It will not pass the request to Spring MVC and your controller.

Refer documentation

like image 160
Alien Avatar answered Sep 20 '22 13:09

Alien