Flask-Signing
a signing key extension for flask
About
The Flask-Signing library is a useful tool for Flask applications that require secure and robust management of signing keys. Do you need to generate single-use tokens for one-time actions like email verification or password reset? Flask-Signing can handle that. Are you looking for a simple method for managing API keys? Look no further.
Installation
First, install the flask_signing package. You can do this with pip:
pip install flask_signing
Basic Usage
After you've installed the flask_signing package, you can use it in your Flask application. Here's an example of how you might do this:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_signing import (
Signatures,
RateLimitExceeded
)
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' # Use your actual database URI
app.secret_key = "Your_Key_Here"
with app.app_context():
signatures = Signatures(app, byte_len=24)
@app.route('/sign')
def sign():
key = signatures.write_key(scope='test', expiration=1, active=True, email='test@example.com')
return f'Key generated: {key}'
@app.route('/verify/<key>')
def verify(key):
try:
valid = signatures.verify_key(signature=key, scope='test')
return f'Key valid: {valid}'
except RateLimitExceeded:
return "Rate limit exceeded"
@app.route('/expire/<key>')
def expire(key):
expired = signatures.expire_key(key)
return f'Key expired: {expired}'
@app.route('/all')
def all():
all = signatures.get_all()
return f'Response: {all}'
In this basic example, a new signing key is generated and written to the database when you visit the /sign route, and the key is displayed on the page. Then, when you visit the /verify/<key> route (replace with the actual key), the validity of the key is checked and displayed. You can expire a key using the /expire/<key> route, and view all records with the /all route.
This is a rather basic example and your actual use of the flask_signing package may be more complex depending on your needs. It's important to secure your signing keys and handle them appropriately according to your application's security requirements. Further usage examples can be found in the examples directory of the Flask-Signing Github repository.
Developers
Contributions are welcome! You can read the developer docs at https://signebedi.github.io/Flask-Signing. If you're interested, review (or add to) the feature ideas at https://github.com/signebedi/Flask-Signing/issues.
Release files for flask-signing 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_signing-0.9.0.tar.gz | 156.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_signing-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 171.0 kB
Release files / flask_signing-0.9.0.tar.gz
| Download URL | flask_signing-0.9.0.tar.gz |
|---|---|
| Size | 156.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96d6ce56e41d445326f0edd6d8d1b1057e836fe5840356cfb5bd5b03e68fbef5
|
|
BLAKE2b-256 checksum How to use checksums |
ddb88825ba77a7f8be13b8aa938a5ce1e404f86c1a7b25d228e8cdc3b9346fc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / flask_signing-0.9.0-py3-none-any.whl
| Download URL | flask_signing-0.9.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ab3f54f3d1fd86e644079a07d2d01be687b9f6528da6b3cabac432da428ad50
|
|
BLAKE2b-256 checksum How to use checksums |
99e3024d7b88ecf675b904a2951b66719c80edd2607eb2b2256cbbb85596709e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|