Git Product home page Git Product logo

drf-simplejwt-react's Introduction

React DRF SimpleJWT App

TL;DR: Django, DRF, DRF SimpleJWT with React Frontend sample.

The purpose of this is to get you started with a secure React-Django project. No need to implement authentication+authorization on your frontend when it's already done for you. You can start by pressing "Use this template"; it's not a fork but a new repository with a fresh initial commit with all the code from here.

Test user: test and pw test.


Example repositories


Introduction

This repository is an example of using React on the front end comminicating with Django, Django Rest Framework and DRF SimpleJWT applications.


Usage

Backend (Django) Instructions.

  1. cd server to get your terminal/cmd into the server directory.
  2. To run the server, create a virtual environment virtualenv venv && source venv/bin/activate, install packages pip install -r requirements.txt -- the requirements.txt file is inside the server subdirectory -- and do python manage.py migrate && python manage.py runserver.
    • Again, make sure when you do this, you are inside the server directory on your terminal/cmd.
    • On Windows, you should do venv\Scripts\activate instead of source venv/bin/activate
  3. If you're writing for an example repository, please create a new directory labeled with the name of the framework (e.g. jwt-ios), and add its .gitignore. Please use the github/gitignore repository. Provide detailed instructions if necessary.

A default user with the username test and password test have been created.

This repository does not come with throttling, but it is highly recommended that you add throttling to your entire project. You can use a third-party package called Django-ratelimit or DRF's internal throttling mechanism. Django-ratelimit is more extensive -- covering Django views, as well -- and thus more supported by SimpleJWT.

Frontend (jwt-react) React instructions.

  1. cd jwt-react to get your terminal/server into the frontend (react) folder.

  2. npm install to install all of the dependencies for the front end application.

  3. npm start and you should be good to go, ensure that your backend is running on port http://localhost:8000, if you run it on another port/ip please change the BASE_URL in jwt-react/src/api/auth.js

  4. Use npm test if you'd like to run the test which tests the api/ folder currently.


License

This repository is licensed under the MIT License.

drf-simplejwt-react's People

Contributors

andrew-chen-wang avatar dependabot-preview[bot] avatar dependabot[bot] avatar dgmouris avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

drf-simplejwt-react's Issues

Cross Site Scripting (XSS) Vulnerability

Both the creators of the JWT standard and OWASP say not to store tokens in local storage as it makes your site vulnerable to cross-site-scripting, yet you store the JWT tokens in local storage (jwt-react/src/api/auth.js).

I'm looking to implement something like this and haven't found a good alternative yet (maybe HTTP cookies but then you need to address CSRF). I'm curious how this could be addressed.

Adding Travis CI for npm and Django test

Adding CI would be great for making sure everything runs smoothly on every commit. It's a good habit to be in test-driven code mode.

Luckily, with JS frameworks, they have nice frontend testing, so I'll be adding npm test and Django tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.