
Research
Security News
Malicious npm Packages Target BSC and Ethereum to Drain Crypto Wallets
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
django-graphql-ratelimit
Advanced tools
Eaiser to use django-ratelimit for graphql in django.
pip install django-graphql-ratelimit
ratelimit key support gql:xxx
, where xxx
is argument.
from django_graphql_ratelimit import ratelimit
class RequestSMSCode(graphene.Mutation):
class Arguments:
phone = graphene.String(required=True)
ok = graphene.Boolean()
@ratelimit(key="ip", rate="10/m", block=True)
@ratelimit(key="gql:phone", rate="5/m", block=True)
def mutate(self, info, phone):
request = info.context
# send sms code logic
return RequestSMSCode(ok=True)
You can use django-ratelimit keys except get:xxx
and post:xxx
:
ip
- Use the request IP address (i.e. request.META['REMOTE_ADDR']
)
I suggest you to use django-ipware to get client ip, modify your MIDDLEWARE
in settings:MIDDLEWARE = [
"django_graphql_ratelimit.middleware.ParseClientIpMiddleware",
...
]
header:x-x
- Use the value of request.META.get('HTTP_X_X', '').user
- Use an appropriate value from request.user. Do not use with unauthenticated users.user_or_ip
- Use an appropriate value from request.user
if the user is authenticated, otherwise use request.META['REMOTE_ADDR']
.FAQs
Use django-ratelimit for graphql
We found that django-graphql-ratelimit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket uncovered four malicious npm packages that exfiltrate up to 85% of a victim’s Ethereum or BSC wallet using obfuscated JavaScript.
Security News
TC39 advances 9 JavaScript proposals, including Array.fromAsync, Error.isError, and Explicit Resource Management, which are now headed into the ECMAScript spec.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.