skillfed

Flask-Cognito

Authenticate users to Cognito user pool via JWT.

flask-cognito v1.21 240.3K downloads/30d#8,906 on PyPI95
Permissive license MIT DORMANT released

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-cognito

uv

uv add flask-cognito

poetry

poetry add flask-cognito

Installing 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

Environment :: Web EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python Modules

Tags

flask cognito jwt authenticationaws cognito flask integrationcognito user pool jwt validationflask jwt auth decoratorcognito group-based access controlserverless flask authenticationcognito token verification flask
aws-cognitojwt-authflask-extension

More Python Modules packages