Skip to main content

Request Signer

Creates and validates signed requests between backend systems.

Requires a SIGNED_REQUEST_API_KEY to be defined in your project's settings.

Usage

Request signer uses requests to make requests, by appending api calls with a X-SignedRequest-Signature header.

There are working examples in the project's django_example and flask_example directories on how to make requests.

Notes:

  • You can pass a company_id and/or user_id to the consuming view which will be available in the view as request.rs_company_id and request.rs_user_id.
  • Views protected by request_signer are assumed to be ADMIN level views and will NOT filter by company or user unless specifically provided. It is up to the requestor to make sure they are not asking for data that those viewing the response should not be allowed to see.

Django

Signing a request

from request_signer.django_utils import signed_request

# GET
signed_request.get('https://localhost:8000')


# POST/PATCH

"""
The request_signer wrapper will jsonify your data object and set the Content-Type to 'application/json'.
"""

data = {'a': 'b'}
signed_request.post('https://localhost:8000', data)
signed_request.patch('https://localhost:8000', data)

Requiring signatures

from rest_framework.views import APIView
from request_signer.django_utils.permissions import APISignature

class SigntureRequiredView(APIView):

    permission_classes = [APISignature]

Flask

Due to the pain of managing app and request contexts, you have to pass the signing key into the request in the Flask library. api_key must be passed as a keyword argument.

Signing a request

from request_signer.flask_utils import signed_request

api_key = app.config['SIGNED_REQUEST_API_KEY']

# GET
signed_request.get('https://localhost:8000', api_key=api_key)


# POST/PATCH

"""
The request_signer wrapper will jsonify your data object and set the Content-Type to 'application/json'.
"""

data = {'a': 'b'}
signed_request.post('https://localhost:8000', data, api_key=api_key)
signed_request.patch('https://localhost:8000', data, api_key=api_key)

Requiring signatures

Seems to be safest if you place the decorator closest to the method definition.

from request_signer.flask_utils.permissions import signature_required

class SigntureRequiredView(BaseView):

    @signature_required
    def get(self, request):
        return 'Good Job'

Building

pip install --upgrade build python3 -m build

Tagging

Update tag whenever semver changes.

git tag -a v1.4 -m "cool message"

Tags don't automatically get pushed; push them up like a normal commit.

git push origin v1.4

Metadata

Release files for request-signer 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for request-signer 0.4.1
File Size Uploaded Provenance Actions
request-signer-0.4.1.tar.gz 6.7 kB Without provenance Details for request-signer-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for request-signer 0.4.1
File Interpreter ABI Platform Actions
request_signer-0.4.1-py3-none-any.whl Python 3 none any Details for request_signer-0.4.1-py3-none-any.whl

Total release size: 14.4 kB

Release files / request-signer-0.4.1.tar.gz

Download URL request-signer-0.4.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e6a3d2d7fbb246780da650dbecc37ac7f7b37595938318cb84e178ff52616232
BLAKE2b-256 checksum
How to use checksums
2075eea55c3166f6a9efb71e10dd544977ac724990029ddcc7e32defb57f7483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.5

Release files / request_signer-0.4.1-py3-none-any.whl

Download URL request_signer-0.4.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bc87b140d3d50c937c90caee56fd180cb5af93e03936fd6949527583d0e79ca
BLAKE2b-256 checksum
How to use checksums
428ad85ef8b55ad1dadd3394e1dc24f38978fa9baeb29a102c9b12a473a8d05b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.5

Security for request-signer 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page