flask-github-signature
A Flask view decorator to verify Github's webhook signatures.
Installation
Using pip
To get the latest version from pypi.org:
pip install flask-github-signature
Usage
export GH_WEBHOOK_SECRET="xyz"
# app.py
from flask import Flask
from flask_github_signature import verify_signature
app = Flask(__name__)
@app.route("/webhook", methods=["POST"])
@verify_signature
def webhook():
return "Payload signature verified."
run the previous Flask app with:
flask run
and test it with:
curl --request POST \
--header "X-Hub-Signature-256: sha256=eba50596a17c2c8fbdbc5c68223422fe41d5310bea51ffdc461430bce0386c54" \
--header "Content-Type: application/json" \
--data '{}' \
http://localhost:5000/webhook
Signing a test payload
If you want to test with another payload you can generate a signature using:
>>> import os
>>> from flask_github_signature import compute_signature
>>>
>>> secret = os.environ["GH_WEBHOOK_SECRET"]
>>> compute_signature(secret, b'{"message": "An example"}')
'04886433fda851ca66181cecbd9c283ba677468ba361b0a0a7ba57a867102b46'
>>>
when using a signature on a header don't forget to append sha256= to it.
Testing
If you want to test, play or contribute to this repo:
git clone git@github.com:pabluk/flask-github-signature.git
cd flask-github-signature/
pip install -r requirements.txt
pip install -r requirements-dev.txt
pytest -v
black --line-length=127 tests/ flask_github_signature/
Metadata
Release files for flask-github-signature 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask-github-signature-0.1.1.tar.gz | 15.3 kB | Without provenance | Details for flask-github-signature-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_github_signature-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for flask_github_signature-0.1.1-py3-none-any.whl |
Total release size: 31.1 kB
Release files / flask-github-signature-0.1.1.tar.gz
| Download URL | flask-github-signature-0.1.1.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c184643ba3aa72a220e6af8f153d04e220f0b9e437f4db78fb7a3e8a4e936aa6
|
|
BLAKE2b-256 checksum How to use checksums |
0877ca235051edcceb4a306c1475ee7de1bfd3d468a217fbacadab25cc696c25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / flask_github_signature-0.1.1-py3-none-any.whl
| Download URL | flask_github_signature-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ffe3adab48f21c23a942c177787f94a8f6d1044a859d86e6c36fea675438886b
|
|
BLAKE2b-256 checksum How to use checksums |
a1ba34c8fed1b256283ab8b52d38e9b16f0eba7dfde4237fa6ebe9cf6f7bf285
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Security for flask-github-signature 0.1.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.