Giter Site home page Giter Site logo

django-firebase-auth's Introduction

Django Firebase Auth

Project provide Django authentication middle ware using Firebase Authentication Service

Requirements

Installation

pip install django-firebase-auth

Generate Firebase Credentials

Usage

Settings

1. Setting credentials

  • Credentials from file
FIREBASE_CREDENTIALS_FILE = '<YOUR FIREBASE CREDENTIALS PATH>'  # 'firebase-credentials.json'
  • or using credentials from json dict (where you can use as environment variables )
Using credentials from json dict
FIREBASE_CREDENTIALS_DICT = {
    "type": "service_account",
    "project_id": "<YOUR PROJECT ID>",
    "private_key_id": "<YOUR PRIVATE KEY ID>",
    "private_key": '<YOUR PRIVATE KEY>',
    "client_email": "<CLIENT EMAIL>",
    "client_id": "<CLIENT ID>",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "<CERT URL>"
}

2. Add installed apps:

INSTALLED_APPS = [
    "...",
    "django_firebase_auth",
]

3. Setting authentication backend

REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "django_firebase_auth.firebase_auth.FirebaseAuthentication",
    ),
}

Generate Firebase Credentials file

To generate a private key file for your service account:

  1. In the Firebase console, open Settings > Service Accounts.
  2. Click Generate New Private Key, then confirm by clicking Generate Key.
  3. Securely store the JSON file containing the key.

Add Firebase credentials to settings.py

Generate Firebase credentials from Firebase console img.png

TODO:

  • Support supabase
  • Optimize session management

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.