Skip to content

kaliif/strawberry-django-auth

 
 

Repository files navigation

Tests Codecov Pypi contributions welcome Pypi downloads Python versions

Strawberry-django Auth

Django registration and authentication with Strawberry.

Demo

Demo Video

About

This Library was inspired by 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 you 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.

Docs can be found here

Features

  • Awesome docs!
  • Captcha validation
  • Async/Sync supported!
  • Works with default or custom user model
  • Builtin JWT authentication using PyJWT
  • User registration with email verification
  • Retrieve/Update user
  • Archive user
  • Permanently delete user or make it inactive
  • Turn archived user active again on login
  • Track user status (archived, verified)
  • Password change
  • Password reset through email
  • Revoke user tokens on account archive/delete/password change/reset
  • All mutations return success and errors
  • Default email templates (you will customize though)
  • Customizable, no lock-in
  • Passwordless registration

Full schema features

@strawberry.type
class AuthMutation:
    # include here your mutations that interact with a user object from a token.

    verify_token = mutations.VerifyToken.field
    update_account = mutations.UpdateAccount.field
    archive_account = mutations.ArchiveAccount.field
    delete_account = mutations.DeleteAccount.field
    password_change = mutations.PasswordChange.field
    swap_emails = mutations.SwapEmails.field

@strawberry.type
class Mutation:
    @field(directives=[TokenRequired()])
    def auth_entry(self) -> Union[AuthMutation, GQLAuthError]:
        return AuthOutput(node=AuthMutation())

    # these are mutation that does not require authentication.
    captcha = Captcha.field
    token_auth = mutations.ObtainJSONWebToken.field
    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
    refresh_token = mutations.RefreshToken.field
    revoke_token = mutations.RevokeToken.field
    verify_secondary_email = mutations.VerifySecondaryEmail.field


schema = strawberry.Schema(query=Query, mutation=Mutation)

Contributing

See CONTRIBUTING.md

About

Authentication system for django using strawberry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 86.7%
  • HTML 12.9%
  • Makefile 0.4%