Flask-Cognito
Authenticate users to Cognito user pool via JWT.
What it is and what it does
Flask-Cognito is a Flask extension that plugs AWS Cognito JWT authentication into your application. It validates incoming JWT tokens from Cognito user pools, extracts user identity from the token payload, and provides decorators to protect routes and enforce group-based access control. The extension sits between your Flask routes and Cognito's identity service, handling token verification and making the authenticated user's claims available to your handlers via context variables.
You configure it with your Cognito region and user pool ID, then decorate routes with @cognito_auth_required to enforce authentication. The package also supports restricting access by Cognito group membership and lets you hook in a custom identity lookup function to map Cognito users to your own database records. It uses cognitojwt internally to handle JWT validation.
Use it for:
- Protect Flask API endpoints by requiring valid Cognito access or ID tokens in the Authorization header.
- Map Cognito user identities to your application's user database for role-based or permission-based access control.
- Enforce group membership restrictions on specific routes using the @cognito_group_permissions decorator.
- Authenticate serverless Flask applications deployed on AWS Lambda that rely on Cognito for identity management.
- Validate JWT tokens without implementing JWT parsing and cryptographic verification yourself.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask-Cognito integrates AWS Cognito JWT authentication into Flask applications, allowing you to protect routes by validating tokens and mapping Cognito identities to your application's user model.
Yes, if you are already committed to AWS Cognito and need straightforward JWT validation in Flask. The package is simple, permissive-licensed, and has no external runtime dependencies. However, maintenance is dormant (latest release 2024-04-13), so verify compatibility with your Flask version and check whether cognitojwt and Cognito's API have evolved. Not recommended if you need active support or are evaluating fresh authentication solutions.
Install
flask-cognito on PyPI
pip
pip install flask-cognitouv
uv add flask-cognitopoetry
poetry add flask-cognitoInstalling Flask-Cognito
Before you install
Installation friction is high. Maintenance is dormant—the last commit was 2024-05-05 and the latest release was 2024-04-13. The repository remains active (95 stars, not archived) but updates are infrequent.
License in practice
Licensed under MIT (permissive), so you may use, modify, and distribute the package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install Flask-Cognito
from flask_cognito import CognitoAuth, cognito_auth_required
app.config.update({
'COGNITO_REGION': 'eu-central-1',
'COGNITO_USERPOOL_ID': 'your-pool-id'
})
cogauth = CognitoAuth(app)
@app.route('/api/private')
@cognito_auth_required
def protected():
return {'status': 'authenticated'}
Requires an AWS Cognito user pool already set up with region and pool ID; Flask and its dependencies must be installed separately.
Verify before relying
- Whether the package works with current versions of Flask and its ecosystem (no Python version constraint specified).
- Whether cognitojwt dependency is automatically installed or must be added manually.
- Current compatibility with modern AWS Cognito API changes since the last release in April 2024.
- How long the package has been dormant and whether it remains compatible with current Flask versions.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 853 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 240,282/month — #8,906 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: Flask-Cognito-1.21.tar.gz
Keywords: flask, aws, cognito, jwt, authentication, auth, serverless
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
fastapi-cognitoDecodes, validates, and parses AWS Cognito JWT…
permissive · top 15,000 on PyPI
Flask-AWSCognitoIntegrates AWS Cognito user authentication into…
permissive · top 15,000 on PyPI
Flask-JWT-ExtendedAdds JSON Web Token (JWT) authentication to…
permissive · top 5,000 on PyPI
pycognitoSimplifies AWS Cognito user authentication and…
permissive · top 5,000 on PyPI
cognitojwtDecodes and verifies Amazon Cognito JWT tokens…
permissive · top 15,000 on PyPI
fastapi-cloudauthIntegrates FastAPI applications with cloud…
permissive · top 15,000 on PyPI
warrantWarrant wraps AWS Cognito user management…
permissive · top 15,000 on PyPI
aws-cdk.aws-cognitoProvides AWS CDK constructs for defining Amazon…
permissive · top 15,000 on PyPI
Flask-HTTPAuthAdds HTTP Basic, Digest, and Token…
permissive · top 5,000 on PyPI
axioms-fastapiAdds OAuth2/OIDC JWT token validation and…
permissive · top 15,000 on PyPI