Skip to main content

a signing key extension for flask

Project description

Signing logo

Flask-Signing

License: BSD-3-Clause PyPI version Flask-Signing tests

a signing key extension for flask

About

The Flask-Signing library is a useful tool for Flask applications that requires secure and robust management of signing keys. This package aids in managing API keys, ensuring only clients with valid permissions can access your resources. Do you need to generate single-use tokens for one-time actions like email verification or password reset? Flask-Signing can handle that. In theory, it can also help manage session IDs. For applications that implement JWT or OAuth2, Flask-Signing can generate and manage the signing keys for your tokens. You can also use it to verify webhook payloads or to implement a licensing system for your software.

Installation

First, install the flask_signing package. You can do this with pip:

pip install flask_signing

Usage

After you've installed the 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

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'  # Use your actual database URI

with app.app_context():
    signatures = Signatures(app, byte_len=24)


@app.route('/sign')
def sign():
    key = signatures.write_key_to_database(scope='test', expiration=1, active=True, email='test@example.com')
    return f'Key generated: {key}'

@app.route('/verify/<key>')
def verify(key):
    valid = signatures.verify_signature(signature=key, scope='example')
    return f'Key valid: {valid}'

@app.route('/expire/<key>')
def expire(key):
    expired = signatures.expire_key(key)
    return f'Key expired: {expired}'
    

In this 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/ route (replace with the actual key), the validity of the key is checked and displayed. Finally, you can expire a key using the /expier/ route.

Please note that this is a very 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_signing-0.2.1.tar.gz (156.3 kB view details)

Uploaded Source

Built Distribution

flask_signing-0.2.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file flask_signing-0.2.1.tar.gz.

File metadata

  • Download URL: flask_signing-0.2.1.tar.gz
  • Upload date:
  • Size: 156.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for flask_signing-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ee8f9209c576a6c878f30bc349d25a2baac771bdc832325e2fdb5fe9488f6e3a
MD5 34cc007fe296daed5a9df447386d30b8
BLAKE2b-256 007b9d5abae088d150d678d1fa852af9c3410619e90bbf6d0ca5381c1774c0ab

See more details on using hashes here.

File details

Details for the file flask_signing-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_signing-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 055b79bf217d2ee95e2040160a3f760143262cbfbe983558782beb99fdf14b4e
MD5 1df905e296065c2bb2b24e6b329cf211
BLAKE2b-256 455af2972b3fb258a3ff6f195543d25b2032e966602e5cc7e779789e2ebb3833

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page