简体   繁体   中英

React authentication Django rest framework

I have a react is frontend that fetches data from an API built with Django rest framework. The front end does not always require a user to be logged in to view content.

Does anyone know the best method of securing these in authenticated requests?

There are various ways of authentication and authorization of your REST apis like OAuth,JWT, Amazon cognito, Basic Auth, Digest Auth etc

The one I prefer is JWT which is secured as well as easy to integrate. You just need to create jwt tokens and save the keys in local storage of react. With this keys you need to call the rest apis, and in django it will verify whether the tokens are correct or not.

For more info you can search on the above mentioned topics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM