Skip to main content

flask-scram

Implements RFC 7804 Salted Challenge Response (SCRAM) HTTP Authentication Mechanism for the Flask web framework.

See requests-scram for a client-side implementation.

Getting Started

Initialize the extension with the application or with init_app in an application factory, and then decorate your route with the login_required method:

from flask import Flask
from flask_scram import Scram


USERNAME = 'user'
PASSWORD = 'pass'

app = Flask(__name__)

db = {}

def auth_fn(username):
    return db[username]

scram = ScramAuth(app, auth_fn=auth_fn)

# or, later in your application factory: scram.init_app(app)

# store your authentication key in your "database"
db[USERNAME] = scram.make_auth_info(PASSWORD)


@app.route("/")
@scram.login_required
def index():
    return "OK"

You may specify the following configuration variables:

  • SCRAM_MECHANISM - supported SCRAM Authentication mechanism e.g. SCRAM-SHA-256
  • SCRAM_REALM - the realm parameter to use e.g. defaults to request.host

You may also use the authenticate method in your code or before request handler.

See scramp for examples of the make_auth_info and make_stored_server_keys functions which the same methods implement.

Todo

License

Licensed under the MIT License.

Metadata

Release files for flask-scram 1.0.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 flask-scram 1.0.1
File Size Uploaded
flask-scram-1.0.1.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-scram 1.0.1
File Interpreter ABI Platform
flask_scram-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / flask-scram-1.0.1.tar.gz

Download URL flask-scram-1.0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a52c307ad33bf679d3e55cb5e2b568d2fd0ff6ba2e3e554490080676b138ec06
BLAKE2b-256 checksum
How to use checksums
9aaac05f9f9dfb5ad592847d6f23f6b8f5ec2d1dc3275d342376ba5f8cffaef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / flask_scram-1.0.1-py3-none-any.whl

Download URL flask_scram-1.0.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a84a0a411445041db03a20c1ee1c4ce4666667f2ee6d5e46dd5414b3b7f2a167
BLAKE2b-256 checksum
How to use checksums
882aa631611b39376d3c057d05b12eae164fba2b757a0b953b44416379ea7a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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