Metadata-Version: 2.1
Name: strawberry-django-auth
Version: 0.3.3.0
Summary: Graphql authentication system with Strawberry for Django.
License: MIT
Author: Nir.J Benlulu
Author-email: nrbnlulu@gmail.com
Maintainer: Nir.J Benlulu
Maintainer-email: nrbnlulu@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: Django (>=3.2,<4); python_version < "3.8"
Requires-Dist: Django (>=3.2,<5); python_version >= "3.8"
Requires-Dist: Pillow (>=9.2.0,<10.0.0)
Requires-Dist: PyJWT (>=1.7.1,<3.0)
Requires-Dist: django-admin-display (>=1.3.0,<2.0.0)
Requires-Dist: importlib-metadata (>=1.7,<5.0); python_version <= "3.7"
Requires-Dist: packaging (>=20.0,<30.0)
Requires-Dist: strawberry-django-jwt (>=0.2.1,<0.3.0)
Requires-Dist: strawberry-graphql (>=0.69.0,<1.0.0)
Requires-Dist: strawberry-graphql-django (>=0.2.5,<4.0)
Project-URL: Documentation, https://nrbnlulu.github.io/strawberry-django-auth/
Project-URL: Homepage, https://github.com/nrbnlulu/strawberry-django-auth
Description-Content-Type: text/markdown


![Tests](https://github.com/nrbnlulu/strawberry-django-auth/actions/workflows/tests.yml/badge.svg)
[![Pypi](https://img.shields.io/pypi/v/strawberry-django-auth.svg)](https://pypi.org/project/strawberry-django-auth/)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nrbnlulu/strawberry-django-auth/blob/master/CONTRIBUTING.md)
# Strawberry-django Auth
[Django](https://github.com/django/django) registration and authentication with [Strawberry](https://strawberry.rocks/).

## Demo

![Demo Video](https://github.com/nrbnlulu/strawberry-django-auth/blob/main/demo.gif)

## About
### This Library is the strawberry version of ![Django-graphql-auth](https://github.com/pedrobern/django-graphql-auth/).

Abstract all the basic logic of handling user accounts out of your app,
so you don't need to think about it and can **get up and running faster**.

No lock-in. When you are ready to implement your own code or this package
is not up to your expectations , it's *easy to extend or switch to
your implementation*.


## Documentation

### Docs can be found [here](https://nrbnlulu.github.io/strawberry-django-auth/)

## Features

* [x] [Awesome docs](https://nrbnlulu.github.io/strawberry-django-auth/):tada:
* [ ] Fully compatible with [Relay](https://github.com/facebook/relay>)
* [x] Works with **default or custom** user model
* [x] JWT authentication *(with [strawberry-django-jwt](https://github.com/KundaPanda/strawberry-django-jwt))*
* [x] User query with filters
* [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 features

```python
import strawberry
from gqlauth.user import arg_mutations as mutations

@strawberry.type
class AuthMutation:
    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
    password_change = mutations.PasswordChange.Field
    archive_account = mutations.ArchiveAccount.Field
    delete_account = mutations.DeleteAccount.Field
    update_account = mutations.UpdateAccount.Field
    send_secondary_email_activation = mutations.SendSecondaryEmailActivation.Field
    verify_secondary_email = mutations.VerifySecondaryEmail.Field
    swap_emails = mutations.SwapEmails.Field
    captcha = mutations.Cap.Field

    # django-graphql-jwt authentication
    # with some extra features
    token_auth = mutations.ObtainJSONWebToken.Field
    verify_token = mutations.VerifyToken.Field
    refresh_token = mutations.RefreshToken.Field
    revoke_token = mutations.RevokeToken.Field

schema = strawberry.Schema(mutation=AuthMutation)
```


## User relay queries

### Currently not supported
expect to find it here when strawberry will natively support relay


## Example

Handling user accounts becomes super easy.

```python
mutation {
  register(
    email: "new_user@email.com",
    username: "new_user",
    password1: "123456super",
    password2: "123456super",
  ) {
    success,
    errors,
    token,
    refreshToken
  }
}
```

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,
    errors
  }
}
```

Now user is verified.

```python
u.status.verified
# True
```



## Contributing

See [CONTRIBUTING.md](https://github.com/nrbnlulu/strawberry-django-auth/blob/master/CONTRIBUTING.md)

