Spring Security to check RestAPI login

I know that this question has been asked many times, but I have not received the answer that I need.

I need a link that can help me create a spring security infrastructure in which I don't want to validate the login form.

This must be done by logging in to RestAPI. I just hit url like -

http://localhost:8080/login 

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

if sucess I could hit protected API requests.

+5
source share
2 answers

I have been using spring and spring security from 1 and a half years with spring protection to develop a rest API. I am using the user authentication method below. Follow the instructions below.

  • Allow access to http: // localhost: 8080 / login for all users
  • The user will pass the username and password in the body
  • User Authentication with Database Record
  • create an access token and send a response
  • using this user access token with interaction with a secure API.

I will provide the source code if you need.

+4
source

I suggest you try using Basic Authentication. I believe that Rest services is a mutual agreement between a consumer and a provider, so create your own service to access the main auth header. Your client needs to pass the encoded base64 value of the username: password. Your service should get the header value and decode, you will return the original data. Check on your backend repository (Ldap or DB).

Learn more about basic authentication. BasicAuthentication

0
source

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


All Articles