# Django Graphene Auth
[Django](https://github.com/django/django) GraphQL registration and authentication
compatible with the latest versions of Django, Django GraphQL JWT
[![downloads](https://img.shields.io/pypi/dm/django-graphene-auth)](https://pypistats.org/packages/django-graphene-auth)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/ptbang/django-graphene-auth)](https://app.codecov.io/github/ptbang/django-graphene-auth/tree)
[![Pypi](https://img.shields.io/pypi/v/django-graphene-auth.svg)](https://pypi.org/project/django-graphene-auth/)
[![Documentation Status](https://readthedocs.org/projects/django-graphene-auth/badge/?version=latest)](https://django-graphene-auth.readthedocs.io/en/latest/?badge=latest)
## About
This project was based on the forked repository from
[Django GraphQL Auth](https://github.com/PedroBern/django-graphql-auth) -
created by *Pedro Bern* (thanks so much for a great job).
The reason I decided to create this project is that the original doesn't support
the newer versions of django, graphene-django and django-graphql-jwt.
Futhermore, it appears that the original one will not be further developed in the near future.
## Documentation
Documentation is available at [read the docs](https://django-graphene-auth.readthedocs.io/en/latest/).
## Features
* [x] [Docs](https://django-graphene-auth.readthedocs.io/en/latest/)
* [x] Fully compatible with [Relay](https://github.com/facebook/relay>)
* [x] Works with **default or custom** user model
* [x] JWT authentication *(with [Django GraphQL JWT](https://github.com/flavors/django-graphql-jwt))*
* [x] User query with filters *(with [Django Filter](https://github.com/carltongibson/django-filter) and [Graphene Django](https://github.com/graphql-python/graphene-django))*
* [x] User registration with email verification
* [x] Add secondary email, with email verification too
* [x] Resend activation email
* [x] Retrieve/Update user
* [x] Archive user
* [x] Permanently delete user or make it inactive
* [x] Turn archived user active again on login
* [x] Track user status (archived, verified, secondary email)
* [x] Password change
* [x] Password reset through email
* [x] Revoke user refresh tokens on account archive/delete/password change/reset
* [x] All mutations return `success` and `errors`
* [x] Default email templates *(you will customize though)*
* [x] Customizable, no lock-in
## Full Schema
```python
import graphene
from graphql_auth.schema import UserQuery, MeQuery
from graphql_auth import mutations
class AuthMutation(graphene.ObjectType):
register = mutations.Register.Field()
verify_account = mutations.VerifyAccount.Field()
resend_activation_email = mutations.ResendActivationEmail.Field()
send_password_reset_email = mutations.SendPasswordResetEmail.Field()
password_reset = mutations.PasswordReset.Field()
password_set = mutations.PasswordSet.Field() # For passwordless registration
password_change = mutations.PasswordChange.Field()
update_account = mutations.UpdateAccount.Field()
archive_account = mutations.ArchiveAccount.Field()
delete_account = mutations.DeleteAccount.Field()
send_secondary_email_activation = mutations.SendSecondaryEmailActivation.Field()
verify_secondary_email = mutations.VerifySecondaryEmail.Field()
swap_emails = mutations.SwapEmails.Field()
remove_secondary_email = mutations.RemoveSecondaryEmail.Field()
# django-graphql-jwt inheritances
token_auth = mutations.ObtainJSONWebToken.Field()
verify_token = mutations.VerifyToken.Field()
refresh_token = mutations.RefreshToken.Field()
revoke_token = mutations.RevokeToken.Field()
class Query(UserQuery, MeQuery, graphene.ObjectType):
pass
class Mutation(AuthMutation, graphene.ObjectType):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
```
## Relay
Import mutations from the ``relay`` module:
```python
from graphql_auth import relay
class AuthMutation(graphene.ObjectType):
register = relay.Register.Field()
# ...
```
## Example
Handling user accounts becomes super easy.
```python
mutation {
register(
email: "new_user@email.com",
username: "new_user",
password1: "123456super",
password2: "123456super",
) {
success,
token, # optional, depending on settings of GRAPHQL_AUTH['ALLOW_LOGIN_NOT_VERIFIED']
refreshToken # optional, depending on settings of GRAPHQL_JWT['JWT_LONG_RUNNING_REFRESH_TOKEN']
}
}
```
Check the status of the new user:
```python
u = UserModel.objects.last()
u.status.verified
# False
```
During the registration, an email with a verification link was sent.
```python
mutation {
verifyAccount(
token:"<TOKEN ON EMAIL LINK>",
) {
success
}
}
```
Now user is verified.
```python
u.status.verified
# True
```
Check the [installation guide](https://django-graphene-auth.readthedocs.io/en/latest/installation/). Or if you prefer, browse the [api](https://django-graphene-auth.readthedocs.io/en/latest/api/).
Raw data
{
"_id": null,
"home_page": "https://github.com/ptbang/django-graphene-auth",
"name": "django-graphene-auth",
"maintainer": "ptbang",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "api graphql rest relay graphene auth jwt",
"author": "ptbang",
"author_email": "ptbang@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1c/c8/45ab7d171b6b26820fe7e744296a2d755888cd4cb33dc12b282a59b18895/django-graphene-auth-1.1.1.tar.gz",
"platform": null,
"description": "# Django Graphene Auth\n\n[Django](https://github.com/django/django) GraphQL registration and authentication\ncompatible with the latest versions of Django, Django GraphQL JWT\n\n[![downloads](https://img.shields.io/pypi/dm/django-graphene-auth)](https://pypistats.org/packages/django-graphene-auth)\n[![Codecov Coverage](https://img.shields.io/codecov/c/github/ptbang/django-graphene-auth)](https://app.codecov.io/github/ptbang/django-graphene-auth/tree)\n[![Pypi](https://img.shields.io/pypi/v/django-graphene-auth.svg)](https://pypi.org/project/django-graphene-auth/)\n[![Documentation Status](https://readthedocs.org/projects/django-graphene-auth/badge/?version=latest)](https://django-graphene-auth.readthedocs.io/en/latest/?badge=latest)\n\n\n## About\n\nThis project was based on the forked repository from\n[Django GraphQL Auth](https://github.com/PedroBern/django-graphql-auth) -\ncreated by *Pedro Bern* (thanks so much for a great job).\n\nThe reason I decided to create this project is that the original doesn't support\nthe newer versions of django, graphene-django and django-graphql-jwt.\nFuthermore, it appears that the original one will not be further developed in the near future.\n\n\n## Documentation\n\nDocumentation is available at [read the docs](https://django-graphene-auth.readthedocs.io/en/latest/).\n\n\n## Features\n\n* [x] [Docs](https://django-graphene-auth.readthedocs.io/en/latest/)\n* [x] Fully compatible with [Relay](https://github.com/facebook/relay>)\n* [x] Works with **default or custom** user model\n* [x] JWT authentication *(with [Django GraphQL JWT](https://github.com/flavors/django-graphql-jwt))*\n* [x] User query with filters *(with [Django Filter](https://github.com/carltongibson/django-filter) and [Graphene Django](https://github.com/graphql-python/graphene-django))*\n* [x] User registration with email verification\n* [x] Add secondary email, with email verification too\n* [x] Resend activation email\n* [x] Retrieve/Update user\n* [x] Archive user\n* [x] Permanently delete user or make it inactive\n* [x] Turn archived user active again on login\n* [x] Track user status (archived, verified, secondary email)\n* [x] Password change\n* [x] Password reset through email\n* [x] Revoke user refresh tokens on account archive/delete/password change/reset\n* [x] All mutations return `success` and `errors`\n* [x] Default email templates *(you will customize though)*\n* [x] Customizable, no lock-in\n\n## Full Schema\n\n```python\n\nimport graphene\n\nfrom graphql_auth.schema import UserQuery, MeQuery\nfrom graphql_auth import mutations\n\nclass AuthMutation(graphene.ObjectType):\n register = mutations.Register.Field()\n verify_account = mutations.VerifyAccount.Field()\n resend_activation_email = mutations.ResendActivationEmail.Field()\n send_password_reset_email = mutations.SendPasswordResetEmail.Field()\n password_reset = mutations.PasswordReset.Field()\n password_set = mutations.PasswordSet.Field() # For passwordless registration\n password_change = mutations.PasswordChange.Field()\n update_account = mutations.UpdateAccount.Field()\n archive_account = mutations.ArchiveAccount.Field()\n delete_account = mutations.DeleteAccount.Field()\n send_secondary_email_activation = mutations.SendSecondaryEmailActivation.Field()\n verify_secondary_email = mutations.VerifySecondaryEmail.Field()\n swap_emails = mutations.SwapEmails.Field()\n remove_secondary_email = mutations.RemoveSecondaryEmail.Field()\n\n # django-graphql-jwt inheritances\n token_auth = mutations.ObtainJSONWebToken.Field()\n verify_token = mutations.VerifyToken.Field()\n refresh_token = mutations.RefreshToken.Field()\n revoke_token = mutations.RevokeToken.Field()\n\n\nclass Query(UserQuery, MeQuery, graphene.ObjectType):\n pass\n\n\nclass Mutation(AuthMutation, graphene.ObjectType):\n pass\n\n\nschema = graphene.Schema(query=Query, mutation=Mutation)\n```\n\n\n## Relay\n\nImport mutations from the ``relay`` module:\n\n```python\n\nfrom graphql_auth import relay\n\nclass AuthMutation(graphene.ObjectType):\n register = relay.Register.Field()\n # ...\n```\n\n\n## Example\n\nHandling user accounts becomes super easy.\n\n```python\nmutation {\n register(\n email: \"new_user@email.com\",\n username: \"new_user\",\n password1: \"123456super\",\n password2: \"123456super\",\n ) {\n success,\n token, # optional, depending on settings of GRAPHQL_AUTH['ALLOW_LOGIN_NOT_VERIFIED']\n refreshToken # optional, depending on settings of GRAPHQL_JWT['JWT_LONG_RUNNING_REFRESH_TOKEN']\n }\n}\n```\n\nCheck the status of the new user:\n\n```python\nu = UserModel.objects.last()\nu.status.verified\n# False\n```\n\nDuring the registration, an email with a verification link was sent.\n\n```python\nmutation {\n verifyAccount(\n token:\"<TOKEN ON EMAIL LINK>\",\n ) {\n success\n }\n}\n```\n\nNow user is verified.\n\n```python\nu.status.verified\n# True\n```\n\nCheck the [installation guide](https://django-graphene-auth.readthedocs.io/en/latest/installation/). Or if you prefer, browse the [api](https://django-graphene-auth.readthedocs.io/en/latest/api/).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Graphql and relay authentication with Graphene for Django.",
"version": "1.1.1",
"project_urls": {
"Documentation": "https://django-graphene-auth.readthedocs.io/en/latest/",
"Homepage": "https://github.com/ptbang/django-graphene-auth"
},
"split_keywords": [
"api",
"graphql",
"rest",
"relay",
"graphene",
"auth",
"jwt"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ef38bce0d779ee5c6f12ef881c2d803d4c5d72794816fd819f69de4faf9f15f",
"md5": "e021c4dc545cd27a3e54b63eeadd9115",
"sha256": "1976e3816dc3e4010fc95dd9b01f57d760bccb10f91da31d6caada14839444e4"
},
"downloads": -1,
"filename": "django_graphene_auth-1.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "e021c4dc545cd27a3e54b63eeadd9115",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 28289,
"upload_time": "2024-03-17T07:17:26",
"upload_time_iso_8601": "2024-03-17T07:17:26.217313Z",
"url": "https://files.pythonhosted.org/packages/4e/f3/8bce0d779ee5c6f12ef881c2d803d4c5d72794816fd819f69de4faf9f15f/django_graphene_auth-1.1.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1cc845ab7d171b6b26820fe7e744296a2d755888cd4cb33dc12b282a59b18895",
"md5": "bb920c2d02d51106ef1b50965ff0760e",
"sha256": "15835885c743935c814ea976b38daf41e86716ee6c3e3576a902d78da494d5ab"
},
"downloads": -1,
"filename": "django-graphene-auth-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "bb920c2d02d51106ef1b50965ff0760e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21351,
"upload_time": "2024-03-17T07:17:28",
"upload_time_iso_8601": "2024-03-17T07:17:28.365424Z",
"url": "https://files.pythonhosted.org/packages/1c/c8/45ab7d171b6b26820fe7e744296a2d755888cd4cb33dc12b282a59b18895/django-graphene-auth-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-17 07:17:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ptbang",
"github_project": "django-graphene-auth",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "django-graphene-auth"
}