Skip to main content

a signing key extension for flask

Project description

Signing logo

Flask-Signing

License: BSD-3-Clause PyPI version Downloads Flask-Signing tests Buy me a coffee

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

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):
    valid = signatures.verify_key(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}'
    
@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.

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.8.0.tar.gz (156.1 kB view details)

Uploaded Source

Built Distribution

flask_signing-0.8.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_signing-0.8.0.tar.gz
  • Upload date:
  • Size: 156.1 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.8.0.tar.gz
Algorithm Hash digest
SHA256 add456522a0e3ad83d493078906863aba32944c4e52ad4cc6f1aa86147c170ea
MD5 f96799ae84be6789d8ea142fdd238c60
BLAKE2b-256 22672cf38748592abc9a81b7cd39c0af045fa6c5a5de1799b22af436853be60b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_signing-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 accf062e94b24cdfa560cc6c090be17e68c1bdad1a1f8d68dfb9ea4c7916f1cd
MD5 a9400755744d4bcafaeb85ca5150160a
BLAKE2b-256 b399a418f5b0da9e9210c37031dd19d84ce4d7402d1692a82b5c8c1c8d100762

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