Giter VIP home page Giter VIP logo

django-allauth-jwt-template's Introduction

Django Allauth JWT Template

demo

All 3rd party authentication is handled by Django Allauth and they are server side rendered(SSR).

A Django project template with Django Allauth and JWT authentication.

Description

This template is for those who want to use JWT for their frontend and backend.

Usage

  1. Copy .env.example to .env and set the environment variables.

    cd backend && cp .env.example .env
  2. Install requirements.

    pip install -r requirements.txt
  3. Migrate and run server.

    cd backend && python manage.py migrate
    cd backend && python manage.py runserver 0.0.0.0:5566
  4. Visit http://localhost:5566.

  5. (Optional) Create a superuser.

    python manage.py createsuperuser
  6. (Optional) Visit http://localhost:5566/admin to see the users.

  7. (Optional) When login with superuser, you can visit http://localhost:5566/api/__hidden_swagger to see the API documentation.

Key Points

  • Allauth Login Login ./backend/authentication/adapter.py.

  • JWT API ./backend/custom_jwt/views.py.

  • Frontend Login

  • Frontend 3rd Party Login Routes

    In this template, I only use Google, Microsoft, and Line as the 3rd party login. You can check the provided in INSTALLED_APPS of ./backend/backend/settings.py.

    The routes are defined in django-allauth and you can find the main pattern in ./backend/authentication/urls.py.

    In the frontend, you can use the following code to login with 3rd party.

    <!-- ./backend/dashboard/templates/index.html -->
    <div id="loginButtons">
        <a title="Google" href="/api/allauth/google/login/?process=login" class="social-login-btn">登入 Google</a>
        <a title="Google" href="/api/allauth/google/login/?process=connect" class="social-login-btn">綁定 Google</a>
        <a title="Microsoft" href="/api/allauth/microsoft/login/?process=login" class="social-login-btn">登入 Microsoft</a>
        <a title="Microsoft" href="/api/allauth/microsoft/login/?process=connect" class="social-login-btn">綁定 Microsoft</a>
        <a title="Line" href="/api/allauth/line/login/?process=login" class="social-login-btn">登入 Line</a>
        <a title="Line" href="/api/allauth/line/login/?process=connect" class="social-login-btn">綁定 Line</a>
    </div>

Misc

I added a file named ./backend/templates/account/messages/logged_in.txt to avoid login success message in Admin login panel.

django-allauth-jwt-template's People

Contributors

natlee avatar

Stargazers

halice avatar  avatar  avatar

Watchers

 avatar

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.