Skip to main content

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


Download files

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

Source Distribution

impact_stack_auth_wsgi_middleware-0.7.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file impact_stack_auth_wsgi_middleware-0.7.0.tar.gz.

File metadata

File hashes

Hashes for impact_stack_auth_wsgi_middleware-0.7.0.tar.gz
Algorithm Hash digest
SHA256 2ae0463a40f7a168656b2ab2cbae69fa83f782d603113a682e723b41e3e669ce
MD5 9afd759247c1ba793b800bd6cd5fd1d5
BLAKE2b-256 c2d608c37ee6621474d9306c66d3e062b5a4916c093825720591c00587cd7150

See more details on using hashes here.

File details

Details for the file impact_stack_auth_wsgi_middleware-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for impact_stack_auth_wsgi_middleware-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac75c26b2d1be9955bfadf8777a3c78da1964e2b3c73ae3b34a3e42f8cbb7d19
MD5 14ca912c178dd9f06a223d9eabf58ae4
BLAKE2b-256 73a41a2fe7bdc9a0313a3e7ba62c33c82524375639190f81b2925fb7d1971721

See more details on using hashes here.

Supported by

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