Coder Social home page Coder Social logo

raab70 / demo-nextauth Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 81 KB

Demo app example for using nextauth JWT authentication with Django Rest Framework

Dockerfile 9.47% Makefile 0.93% JavaScript 10.75% CSS 10.85% TypeScript 25.89% Python 42.11%

demo-nextauth's Introduction

Demo NextAuth JWT with Django Rest Framework

Running The Demo

When you're ready, start your application by running: docker compose up --build.

You'll want to create a user by posting to the API which is available on port 8000. httpie makes this easy but you can use any other tool.

http POST http://localhost:8000/api/accounts/register/ username=test email='[email protected]' password1=adminpass password2=adminpass

Once you have an account registered you can use it to login.

Visit http://localhost:3000/ and click login. This will take you to the nextauth signin page

Use the above username and password to login! Then you can click on your profile icon to test logging out.

Local Development Environment

Backend

pip install pip poetry wheel setuptools -U
poetry config virtualenvs.in-project true
poetry install --no-root
make run

The API server is now running on port 8000

ref

Frontend

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
echo 'export PATH="$PATH:$NVM_DIR"' >> ~/.bashrc
nvm install --lts
npm install -g pnpm
cd flash && pnpm install
AUTH_SECRET=supersecret pnpm dev

The node server is now running at http://localhost:3000

Authentication

You can use the following flows to test out some authentication endpoints using httpie

http POST http://localhost:8000/api/accounts/register/ username=test email='[email protected]' password1=adminpass password2=adminpass
TOKEN=$(http POST http://localhost:8000/api/accounts/auth/login/ username='test' password=adminpass | jq -r '.access')
http http://localhost:8000/api/accounts/auth/user/ Authorization:"Bearer $TOKEN"
http POST http://localhost:8000/api/accounts/token/verify/ token="$TOKEN"

200 means the token is valid, 4xx means it is no longer valid

http POST http://localhost:8000/api/accounts/auth/logout/ Authorization:"Bearer $TOKEN"

demo-nextauth's People

Contributors

raab70 avatar

Watchers

Drew Franz avatar  avatar

Forkers

drewfranz

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.