Giter Club home page Giter Club logo

django-graphql-ratelimit's People

Contributors

o3o3o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

django-graphql-ratelimit's Issues

Is this project no longer supported?

Hi,
I just installed the package and had issues importing it.

In [1]: from django_graphql_ratelimit import ratelimit
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-b33a7968dd74> in <module>
----> 1 from django_graphql_ratelimit import ratelimit

/usr/local/lib/python3.8/site-packages/django_graphql_ratelimit/__init__.py in <module>
----> 1 from .ratelimit import GQLRatelimitKey, ratelimit  # noqa

/usr/local/lib/python3.8/site-packages/django_graphql_ratelimit/ratelimit.py in <module>
      1 import logging
----> 2 from ratelimit import ALL
      3 from functools import wraps
      4 from ratelimit.exceptions import Ratelimited
      5 from ratelimit.utils import is_ratelimited

ModuleNotFoundError: No module named 'ratelimit'

Set rate limit for Django-graphql-jwt custom token auth mutation.

from django_graphql_ratelimit import ratelimit
from django.utils.decorators import method_decorator

class CustomTokenAuth(ObtainJSONWebToken):

    @classmethod
    @method_decorator(ratelimit(key='gql:username', rate='0/s', block=True))
    def resolve(cls, root, info, **kwargs):

        user = info.context.user
        role = user.profile.role
        logger.info('USER_LOGIN: %s', user)

        if role == 'student':
            student = user.student
            student.check_login_permission()

        user.last_login = timezone.now()
        user.save()

        return cls()


class Mutation(
    api.schema.Mutation,
    # other mutations ...
):
    token_auth = CustomTokenAuth.Field()

I want to set api rate limit for graphql-jwt tokenAuth mutation to prevent brute-force attack.
I set cache backend correctly and verified it's working.
image
But, this does not limit api request rate.

Is there any solution to set API request limit for graphql tokenAuth mutation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.