Django Rest Framework Firebase Authentication
This package provides a base Firebase Authentication backend class for the Django rest framework. Two key methods are not implemented for more flexebility. Let's keep it simple, stupid.
Requirements
- Python 2.7 or 3.4+
- Django (version 1.11+)
- Django Rest Framework
- Firebase Admin Python
Installation
pip install drf-firebase-authentication
Usage
1. Subclass BaseFirebaseAuthentication and implement its template methods:
Decide by yourself how you want to associate Firebase users with local django users by implementing the .get_django_user() method accordingly.
Put your code into a authentication.py file inside an app dedicated to your projects REST Api.
from drf_firebase.authentication import BaseFirebaseAuthentication
from firebase_admin import credentials, initialize_app
from django.contrib.auth import get_user_model
firebase_creds = credentials.Certificate('path/to/firebase/credentials.json')
firebase_app = initialize_app(firebase_creds)
class FirebaseAuthentication(BaseFirebaseAuthentication):
"""
Example implementation of a DRF Firebase Authentication backend class
"""
def get_firebase_app(self):
return firebase_app
def get_django_user(self, firebase_user_record):
return get_user_model().objects.get_or_create(
username=firebase_user_record.uid,
)[0]
2. Add the just created Firebase authentication backend to your settings.py:
Replace YOUR_RESTAPI_APP with the app you put your authentication.py file in.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication', # default
'rest_framework.authentication.BasicAuthentication', # default
'YOUR_RESTAPI_APP.authentication.FirebaseAuthentication',
),
}
Metadata
Release files for drf-firebase-authentication 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf-firebase-authentication-1.0.1.tar.gz | 4.0 kB | Without provenance | Details for drf-firebase-authentication-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_firebase_authentication-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for drf_firebase_authentication-1.0.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / drf-firebase-authentication-1.0.1.tar.gz
| Download URL | drf-firebase-authentication-1.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
374fe447a04da5161230ab3f247eb7c67a6ef4c139dd3ac52077287837191db8
|
|
BLAKE2b-256 checksum How to use checksums |
3e88d99f49787f0d6f92c251eab25b295b7a213be0a933a87dbd3f207f61695c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0
|
Release files / drf_firebase_authentication-1.0.1-py3-none-any.whl
| Download URL | drf_firebase_authentication-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19cf7a924eac4b4814b04c9b9c6fd22d77af628da1e273ba1bcbdfb364510c31
|
|
BLAKE2b-256 checksum How to use checksums |
d604b273b2eda5c4a38e1328c42c28b6d155fa5a6ae8a4a59cae468a7caf4efe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0
|
Security for drf-firebase-authentication 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.