User Authentication with ASP MVC and React

In C # and with complaints, it's easy to set up a login system. I am wondering how to do this correctly using React and C # as source code?

I need to send login and password from a React form using xmlhttp post request and check if it exists? Should I then setup claims , and then what? Send and ID as a JSON result and save it in my local storage? For me this does not make sense, since there are already complaints. Or should I check if there are any complaints with every update, and if so, send at least an ID to view React?

Any ideas?

+5
source share
1 answer

General authentication for SPA centers and REST servers is currently a token carrier. See RFC 6750 . General extension on the JWT carrier token (JSON Web tokens). The linked page contains links to many JWT.Net libraries, such as System.IdentityModel.Tokens.Jwt .

Your application should display the login form, then perform a REST POST on the authentication endpoint in order to receive the JWT token. Then the token can contain everything you want, including identifiers and claims. The next step is to make sure that your spa injects a token into each individual request so that it is authenticated by the back end. This, of course, is entirely dependent on how your application interacts with the back end, as the β€œresponsive” does not affect this part. For example, for Redux, see this .

+4
source

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


All Articles