Graphql authentication system with Strawberry for Django.
Project description
Strawberry-django Auth
Django registration and authentication with Strawberry.
Demo
About
This Library is the strawberry version of .
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
Features
- Awesome docs:tada:
- Fully compatible with Relay
- Works with default or custom user model
- JWT authentication (with strawberry-django-jwt)
- User query with filters
- User registration with email verification
- Add secondary email, with email verification too
- Resend activation email
- Retrieve/Update user
- Archive user
- Permanently delete user or make it inactive
- Turn archived user active again on login
- Track user status (archived, verified, secondary email)
- Password change
- Password reset through email
- Revoke user refresh tokens on account archive/delete/password change/reset
- All mutations return
success
anderrors
- Default email templates (you will customize though)
- Customizable, no lock-in.
Full schema features
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.
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:
u = UserModel.objects.last()
u.status.verified
# False
During the registration, an email with a verification link was sent.
mutation {
verifyAccount(
token:"<TOKEN ON EMAIL LINK>",
) {
success,
errors
}
}
Now user is verified.
u.status.verified
# True
Contributing
See CONTRIBUTING.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for strawberry-django-auth-0.3.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b4b3bfad6d123677bb989b140c4dbc17b48b61628dab125cf9c8470af6a69b2 |
|
MD5 | 445baf491d5f46a8cdd47c30ed0e8aba |
|
BLAKE2b-256 | a67a8c0831618237a730b31e6aba9537b1aeafd1461517f154dd578dffb0c0f1 |
Hashes for strawberry_django_auth-0.3.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d4845de840e13379244b0830842e99e1f88981fe42ede5b649cac0b0e39e63a |
|
MD5 | bac64f5a3fa379a95d9d8aa124278887 |
|
BLAKE2b-256 | acf8aa00048f2280c3bff59177794d701276582c9d8ddedbec84131ca2394796 |