Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
drf-link-navigation-pagination
Advanced tools
Yet another pagination class for DRF to set host address by header
Yet another thirdy party package for DRF Pagination.
This package adds support to some headers that allow you to configure the behaviour of the LimitOffsetPagination class.
If you want to change de host address located on next
and previous
fields, then this is the right thing to you. Take this body as an example:
{
"links": {
"next": "http://localhost/api/v1/entities/?limit=1&offset=2",
"previous": "http://localhost/api/v1/entities/limit=1"
},
"count": 100,
"results": [
{
"id": "bc6c6868-4e4d-4381-a785-f353ee7ecce5"
}
]
}
Using a reverse proxy (like AWS API Gateway) to intermediate between your API, adding X-Drf-Change-Domain=chumaco
header to the request will make the client receive the following:
{
"links": {
"next": "http://chumaco/api/v1/entities/?limit=1&offset=2",
"previous": "http://chumaco/api/v1/entities/limit=1"
},
"count": 100,
"results": [
{
"id": "bc6c6868-4e4d-4381-a785-f353ee7ecce5"
}
]
}
This header allows you to define different limits to the pagination depending on the gateway you are exposing your API.
For example. For client A we allow a max of 50
entries, for client B we allow a max of 100
you can by injecting
this header on the client's requests.
If for some reason the client exceeds the limit he will receive a Bad Request Error:
{
"detail": "Bad limit value sent.",
"error": {
"code": "bad_limit_value"
},
"type": "API_EXCEPTION"
}
Otherwise the default paginated response is generated:
{
"links": {
"next": "https://chumaco/api/v1/entities/?limit=1&offset=2",
"previous": "https://chumaco/api/v1/entities/limit=1"
},
"count": 100,
"results": [
{
"id": "bc6c6868-4e4d-4381-a785-f353ee7ecce5"
}
]
}
To use this package after installing you need to use it's pagination class. in your settings.py
do the following:
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "drf_link_navigation_pagination.LinkNavigationPagination",
...
}
In order to execute the tests:
pipenv run tox
FAQs
Yet another pagination class for DRF to set host address by header
We found that drf-link-navigation-pagination 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.