{"id":21380302,"url":"https://github.com/moreonion/impact-stack-auth-wsgi-middleware","last_synced_at":"2025-10-05T13:19:44.064Z","repository":{"id":232843569,"uuid":"719614177","full_name":"moreonion/impact-stack-auth-wsgi-middleware","owner":"moreonion","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-30T13:28:50.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-22T22:43:48.497Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moreonion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-16T14:39:30.000Z","updated_at":"2023-11-16T14:40:21.000Z","dependencies_parsed_at":"2024-04-11T20:23:00.363Z","dependency_job_id":"2323b2be-3194-48ef-986a-63509819ecc4","html_url":"https://github.com/moreonion/impact-stack-auth-wsgi-middleware","commit_stats":null,"previous_names":["moreonion/impact-stack-auth-wsgi-middleware"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreonion%2Fimpact-stack-auth-wsgi-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreonion%2Fimpact-stack-auth-wsgi-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreonion%2Fimpact-stack-auth-wsgi-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moreonion%2Fimpact-stack-auth-wsgi-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moreonion","download_url":"https://codeload.github.com/moreonion/impact-stack-auth-wsgi-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243857988,"owners_count":20359259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T10:39:32.133Z","updated_at":"2025-10-05T13:19:39.030Z","avatar_url":"https://github.com/moreonion.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WSGI authentication middleware\n\nThis app is just one piece in our bigger [authorization scheme for microservices](https://docs.google.com/document/d/1wbdSyAU0OV0e2rH-nh_IiJkgNDWyKXhptsJwIff64A0/edit?usp=sharing).\nIts 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.\n\n## Architecture decisions\n\n* The session UUIDs are stored in a redis database that can be reached by the wrapped Flask app.\n* The session UUIDs are passed as cookie values.\n* 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.\n* The session UUIDs in the cookie are signed using `itsdangerous`. The middleware only handles session UUIDs with a valid signature.\n\n## Usage\n\n```python\nfrom impact_stack.auth_wsgi_middleware import AuthMiddleware\n\napp = Flask(__name__)\nAuthMiddleware.init_app(app)\n```\n\n## Configuration variables\n\nThe middleware reads its configuration from the Flask `app.config` dictionary. All variables are prefixed with `AUTH_…`.\n\n| variable                  | description                                                                                                                                                   |\n|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `AUTH_SECRET_KEY`         | The secret key used to verify the cookie value’s signature. It defaults to `SECRET_KEY`.                                                                      |\n| `AUTH_SIGNATURE_ALGORITHM`| A hash function to use as digest method for signing the session IDs. Defaults to `hashlib.sha256`                                                             |\n| `AUTH_COOKIE_NAME`        | Name of the cookie from which the the session UUID is read. Defaults to `session_uuid`.                                                                       |\n| `AUTH_REDIS_URL`          | URL to a redis database (see the [redis-py documentation](https://redis-py.readthedocs.io/en/latest/#redis.Redis.from_url) for more information)).            |\n| `AUTH_REDIS_CLIENT_CLASS` | The redis client class used by the middleware. Mostly needed for testing. Defaults to [`redis.Redis`](https://redis-py.readthedocs.io/en/latest/#redis.Redis) |\n| `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'`.           |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoreonion%2Fimpact-stack-auth-wsgi-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoreonion%2Fimpact-stack-auth-wsgi-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoreonion%2Fimpact-stack-auth-wsgi-middleware/lists"}