# graphene-django-firebase-auth
Authentication provider for graphene-django and Firebase's Authentication service.
Note this is a WIP and abandoned project since I never ended up using Firebase. But the code is still a good starting
point as of writing this.
Partially inspired by
[django-firebase-auth](https://github.com/fcornelius/django-firebase-auth)
for Django REST framework.
This app is used with [Firebase Authentication](https://firebase.google.com/docs/auth/) on a client.
## Compatibility
This code has only been tested with Python `3.7.0` and Django `2.1.2`.
## Installing
1. Install the app:
```sh
pipenv install graphene-django-firebase-auth
```
2. Download the JSON file from your [Firebase console](https://console.firebase.google.com/) with your account's
credentials.
3. Set `FIREBASE_KEY_FILE` in your project's settings to the path of the credentials file:
```python
import os
FIREBASE_KEY_FILE = os.path.join(BASE_DIR, 'path/to/firebase-credentials.json')
```
4. Add the authentication backend to `AUTHENTICATION_BACKENDS`:
```python
AUTHENTICATION_BACKENDS = ['firebase_auth.authentication.FirebaseAuthentication']
```
5. Add `firebase_auth` to `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
'firebase_auth',
]
```
6. Add `FirebaseAuthMixin` to your `AUTH_USER_MODEL`:
```python
class User(PermissionsMixin, FirebaseAuthMixin):
```
7. Build and run your DB migrations to add the changes:
```sh
./manage.py makemigrations
./manage.py migrate
```
## Sending tokens on the client
Your client will need to send an `Authorization: Bearer` token on each request. How you do this depends on your client
and is outside the scope
of this documentation.
## Developing
### Setting up your environment
1. Install the dependencies:
```sh
pipenv install -d
```
2. Download the JSON file from your [Firebase console](https://console.firebase.google.com/) with your account's
credentials.
3. Create an `.env` file using `.env.example` as a template. Make sure
to specify the path to the file in the previous step.
4. Enter the virtual environment:
```sh
./manage.py shell
```
### Other commands
```sh
# Run the tests
./manage.py test
```
```sh
# Lint the code
./lint.sh
```
Raw data
{
"_id": null,
"home_page": "https://github.com/dspacejs/graphene-django-firebase-auth",
"name": "graphene-django-firebase-auth",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "graphene django firebase auth",
"author": "Daniel Spajic",
"author_email": "daniel@danieljs.tech",
"download_url": "https://files.pythonhosted.org/packages/5e/ab/b22bc763444c9a556d73cc082b02af265313904e8c87467aa9f527819bbd/graphene_django_firebase_auth-0.0.22.tar.gz",
"platform": null,
"description": "# graphene-django-firebase-auth\n\nAuthentication provider for graphene-django and Firebase's Authentication service.\n\nNote this is a WIP and abandoned project since I never ended up using Firebase. But the code is still a good starting\npoint as of writing this.\n\nPartially inspired by\n[django-firebase-auth](https://github.com/fcornelius/django-firebase-auth)\nfor Django REST framework.\n\nThis app is used with [Firebase Authentication](https://firebase.google.com/docs/auth/) on a client.\n\n## Compatibility\n\nThis code has only been tested with Python `3.7.0` and Django `2.1.2`.\n\n## Installing\n\n1. Install the app:\n\n```sh\npipenv install graphene-django-firebase-auth\n```\n\n2. Download the JSON file from your [Firebase console](https://console.firebase.google.com/) with your account's\n credentials.\n\n3. Set `FIREBASE_KEY_FILE` in your project's settings to the path of the credentials file:\n\n```python\nimport os\nFIREBASE_KEY_FILE = os.path.join(BASE_DIR, 'path/to/firebase-credentials.json')\n```\n\n4. Add the authentication backend to `AUTHENTICATION_BACKENDS`:\n\n```python\nAUTHENTICATION_BACKENDS = ['firebase_auth.authentication.FirebaseAuthentication']\n```\n\n5. Add `firebase_auth` to `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n'firebase_auth',\n]\n```\n\n6. Add `FirebaseAuthMixin` to your `AUTH_USER_MODEL`:\n\n```python\nclass User(PermissionsMixin, FirebaseAuthMixin):\n```\n\n7. Build and run your DB migrations to add the changes:\n\n```sh\n./manage.py makemigrations\n./manage.py migrate\n```\n\n\n\n## Sending tokens on the client\n\nYour client will need to send an `Authorization: Bearer` token on each request. How you do this depends on your client\nand is outside the scope\nof this documentation.\n\n## Developing\n\n### Setting up your environment\n\n1. Install the dependencies:\n\n```sh\npipenv install -d\n```\n\n2. Download the JSON file from your [Firebase console](https://console.firebase.google.com/) with your account's\n credentials.\n\n3. Create an `.env` file using `.env.example` as a template. Make sure\n to specify the path to the file in the previous step.\n\n4. Enter the virtual environment:\n\n```sh\n./manage.py shell\n```\n\n### Other commands\n\n```sh\n# Run the tests\n./manage.py test\n```\n\n```sh\n# Lint the code\n./lint.sh\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Authentication provider for graphene-django and Google Firebase's Authentication service.",
"version": "0.0.22",
"project_urls": {
"Homepage": "https://github.com/dspacejs/graphene-django-firebase-auth"
},
"split_keywords": [
"graphene",
"django",
"firebase",
"auth"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ca9c2beba0415bf08869d35ec9ff16ca98c17ff4b7d17d07a00e1e12e4c492f7",
"md5": "70b42d43df3212597c1a566444bdd03e",
"sha256": "08957a69662fb3dfb549b20a2493b11eb67e8c1ed342fd9bccf9f0fc8cce64e8"
},
"downloads": -1,
"filename": "graphene_django_firebase_auth-0.0.22-py3-none-any.whl",
"has_sig": false,
"md5_digest": "70b42d43df3212597c1a566444bdd03e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5671,
"upload_time": "2023-06-09T10:30:22",
"upload_time_iso_8601": "2023-06-09T10:30:22.332730Z",
"url": "https://files.pythonhosted.org/packages/ca/9c/2beba0415bf08869d35ec9ff16ca98c17ff4b7d17d07a00e1e12e4c492f7/graphene_django_firebase_auth-0.0.22-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5eabb22bc763444c9a556d73cc082b02af265313904e8c87467aa9f527819bbd",
"md5": "ce8016538957cd77c450b8df59fe0991",
"sha256": "da3b6f44f42196bb1c385fc0e23da2b50bb89aca08611ed56b3f890bcc9914b3"
},
"downloads": -1,
"filename": "graphene_django_firebase_auth-0.0.22.tar.gz",
"has_sig": false,
"md5_digest": "ce8016538957cd77c450b8df59fe0991",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4468,
"upload_time": "2023-06-09T10:30:23",
"upload_time_iso_8601": "2023-06-09T10:30:23.537086Z",
"url": "https://files.pythonhosted.org/packages/5e/ab/b22bc763444c9a556d73cc082b02af265313904e8c87467aa9f527819bbd/graphene_django_firebase_auth-0.0.22.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-09 10:30:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dspacejs",
"github_project": "graphene-django-firebase-auth",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "graphene-django-firebase-auth"
}