Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security to Validate login RestAPI

I know this question asked many times but I did not get answer that I required.

I want link that can help me to create a spring security framework, In which I donot whant login form validation.

It should be done by login RestAPI. I just hit url like-

http://localhost:8080/login 

post request containing username and password and it return json response with sucess or failure status

if sucess I would be able to hit secure API Requests.

like image 778
Anupam Sharma Avatar asked Sep 30 '22 05:09

Anupam Sharma


1 Answers

I am using spring and spring security since 1 and half year with spring security to develop rest API I use below technique for user authentication Follow below steps

  1. Allow to access http:// localhost:8080/login for all user
  2. User will pass username and password in body
  3. Authenticate user with database entry
  4. create access token and send back to response
  5. using this access token user with interact with secure API.

I will provide source code if you need.

like image 198
HiteshR Avatar answered Oct 04 '22 04:10

HiteshR