How to handle user logins using Spring MVC?

I am using Spring MVC for a web application. I want to use OpenID for my application, but I'm just wondering what a good way to handle authentication in general for Spring MVC.

My web application is a question and answer. Here is the scenario in which I am confused:
When the user wants to ask a question, he enters the question into the text box and clicks submit, and he sends the form to "/ question / create", which maps to the Create method in my Question controller. At this stage, if they log into the system, he will add the question to the database, but if they do not, I would like them to see the login screen, and then after the successful login, the question will be added to the database.

I donโ€™t understand how to automatically add a question to the database after the login screen, since the form values โ€‹โ€‹will have the form values โ€‹โ€‹for the login screen, and not the form values โ€‹โ€‹for adding the question screen anymore.

+4
source share
4 answers

acegi or spring security is what you need.

http://static.springsource.org/spring-security/site/faq.html

Any non-authenticated user will be redirected to the login page and after successful authentication the requested action can be performed. Acegi provides this facility.

+3
source

Spring Security is a Spring authentication method and has support for OpenID authentication since version 2.0 . See Section 2.3.4. OpenID Login in the official reference guide .

+6
source

You should check OpenID for Java: http://code.google.com/p/openid4java/ I would think this is the best way to do this.

+3
source

You should check spring security . It has everything you need and much more.

+1
source

Source: https://habr.com/ru/post/1299182/


All Articles