o3o3o / django-graphql-ratelimit Goto Github PK
View Code? Open in Web Editor NEWEasier to use django-ratelimit for graphql in django.
Home Page: https://pypi.org/project/django-graphql-ratelimit/
Easier to use django-ratelimit for graphql in django.
Home Page: https://pypi.org/project/django-graphql-ratelimit/
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'
Hi, thanks for the project.
I need to raise an error when the user blocked.
how can I do this?
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.
But, this does not limit api request rate.
Is there any solution to set API request limit for graphql tokenAuth mutation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.