# 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/eba-alemayehu/graphene-django-firebase-auth",
"name": "django-graphene-firebase-auth",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "graphene django firebase auth",
"author": "Eba Alemayehu",
"author_email": "ebaalemayhu3@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f9/92/54ad52818bb84f26284be1df79f30b2c59c80dd4ae4651be2870dc4db915/django_graphene_firebase_auth-0.0.32.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.32",
"project_urls": {
"Homepage": "https://github.com/eba-alemayehu/graphene-django-firebase-auth"
},
"split_keywords": [
"graphene",
"django",
"firebase",
"auth"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f26b63b05c5bfdfc179278c3e67cc81d89f35eab3506f641b1c14364ca75ada3",
"md5": "b23b31cfd3e2808feffc5030ae04018a",
"sha256": "aaf0678515cab6c9dd769aa3b260858830821d948cdc24647e62eec139276fe6"
},
"downloads": -1,
"filename": "django_graphene_firebase_auth-0.0.32-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b23b31cfd3e2808feffc5030ae04018a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5847,
"upload_time": "2024-11-14T09:40:06",
"upload_time_iso_8601": "2024-11-14T09:40:06.862993Z",
"url": "https://files.pythonhosted.org/packages/f2/6b/63b05c5bfdfc179278c3e67cc81d89f35eab3506f641b1c14364ca75ada3/django_graphene_firebase_auth-0.0.32-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f99254ad52818bb84f26284be1df79f30b2c59c80dd4ae4651be2870dc4db915",
"md5": "a8a0da409a5fa684f2103be634e900fc",
"sha256": "b53a5c377017488d0fd48ef011f45b84105f7137c86ab28d65ae3d83b9848df7"
},
"downloads": -1,
"filename": "django_graphene_firebase_auth-0.0.32.tar.gz",
"has_sig": false,
"md5_digest": "a8a0da409a5fa684f2103be634e900fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4717,
"upload_time": "2024-11-14T09:40:08",
"upload_time_iso_8601": "2024-11-14T09:40:08.395538Z",
"url": "https://files.pythonhosted.org/packages/f9/92/54ad52818bb84f26284be1df79f30b2c59c80dd4ae4651be2870dc4db915/django_graphene_firebase_auth-0.0.32.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-14 09:40:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eba-alemayehu",
"github_project": "graphene-django-firebase-auth",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-graphene-firebase-auth"
}