No project description provided
Project description
WSGI authentication middleware
This app is just one piece in our bigger authorization scheme for microservices. Its purpose is make migrating to session cookies simpler by ensuring that backend microservices only need to deal with JWTs that contain all the needed claims.
Architecture decisions
- The session UUIDs are stored in a redis database that can be reached by the wrapped Flask app.
- The session UUIDs are passed as cookie values.
- The redis database contains a JWT for each valid session UUID. The middleware doesn’t care about the actual contents of the JWT it just needs to be there.
- The session UUIDs in the cookie are signed using
itsdangerous
. The middleware only handles session UUIDs with a valid signature.
Usage
from impact_stack.auth_wsgi_middleware import AuthMiddleware
app = Flask(__name__)
AuthMiddleware.init_app(app)
Configuration variables
The middleware reads its configuration from the Flask app.config
dictionary. All variables are prefixed with AUTH_…
.
variable | description |
---|---|
AUTH_SECRET_KEY |
The secret key used to verify the cookie value’s signature. It defaults to SECRET_KEY . |
AUTH_SIGNATURE_ALGORITHM |
A hash function to use as digest method for signing the session IDs. Defaults to hashlib.sha256 |
AUTH_COOKIE_NAME |
Name of the cookie from which the the session UUID is read. Defaults to session_uuid . |
AUTH_REDIS_URL |
URL to a redis database (see the redis-py documentation for more information)). |
AUTH_REDIS_CLIENT_CLASS |
The redis client class used by the middleware. Mostly needed for testing. Defaults to redis.Redis |
AUTH_HEADER_TYPE |
Prefix used when adding the JWT to the HTTP Authorization header. Defaults to the value of JWT_HEADER_TYPE which in turn defaults to 'Bearer' . |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file impact-stack-auth-wsgi-middleware-0.5.2.tar.gz
.
File metadata
- Download URL: impact-stack-auth-wsgi-middleware-0.5.2.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e86f4526b65ddccabcee89fa225bf18a01d664b08fcd5d5b8018e623619bf41e |
|
MD5 | 13ad81e7d64ea53d6e2175cb427dcdfa |
|
BLAKE2b-256 | 56001619662151b42577e3022c76d4c016e480bdc7bad631f1e95c8e0951fabb |
File details
Details for the file impact_stack_auth_wsgi_middleware-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: impact_stack_auth_wsgi_middleware-0.5.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ee3abde180f36a3e18d359b07aa046bc6957e6428b5cf069fb72f3402e606d4 |
|
MD5 | 9a6edcf965b33b1a2ea446737abc3003 |
|
BLAKE2b-256 | 4fb2ef933265f9a0fa764bba3e10083d53d124fb63a93a4d1a16ecf55ba4bbdc |