Skip to main content

Strawberry-graphql port of the graphene-django-jwt package

Reason this release was yanked:

Should have been a pre-release

Project description

Strawberry Django JWT

PyPI - Downloads GitHub commit activity GitHub last commit

JSON Web Token authentication for Strawberry Django GraphQL


Disclaimer

This project is a forked version of Django GraphQL JWT that substitutes Graphene GraphQL backend for Strawberry


Installation

  1. Install last stable version from Pypi:

    pip install strawberry-django-jwt
    
  2. Add AuthenticationMiddleware middleware to your MIDDLEWARE settings:

    MIDDLEWARE = [
        ...,
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        ...,
    ]
    
  3. Add JSONWebTokenMiddleware middleware to your STRAWBERRY schema definition:

    from strawberry_django_jwt.middleware import JSONWebTokenMiddleware
    from strawberry import Schema
    
    schema = Schema(...)
    schema.middleware.extend([
         JSONWebTokenMiddleware(),
    ])
    
  4. Add JSONWebTokenBackend backend to your AUTHENTICATION_BACKENDS:

    AUTHENTICATION_BACKENDS = [
        'strawberry_django_jwt.backends.JSONWebTokenBackend',
        'django.contrib.auth.backends.ModelBackend',
    ]
    
  5. Add django-graphql-jwt mutations to the root schema:

    import strawberry
    import strawberry_django_jwt.mutations as jwt_mutations
    
    @strawberry.type
    class Mutation:
        token_auth = jwt_mutations.ObtainJSONWebToken.obtain
        verify_token = jwt_mutations.Verify.verify
        refresh_token = jwt_mutations.Refresh.refresh
        delete_token_cookie = jwt_mutations.DeleteJSONWebTokenCookie.delete_cookie
    
    
    schema = strawberry.Schema(mutation=Mutation, query=...)
    

Documentation

Work in Progress

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

strawberry-django-jwt-0.1.0.tar.gz (23.5 kB view hashes)

Uploaded Source

Built Distribution

strawberry_django_jwt-0.1.0-py3-none-any.whl (44.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page