Skip to main content

daylily-auth-cognito

daylily-auth-cognito is the standalone Cognito auth repo for Daylily. It publishes the daylily_auth_cognito Python package and the daycog CLI.

The 2.0 line is a breaking refactor with hard boundaries:

  • runtime/: JWT verification and FastAPI bearer auth
  • browser/: Hosted UI session auth with token-free session storage
  • admin/: Cognito pool, app-client, user, password, and federation mutations
  • cli/: daycog wiring only
  • policy/: email-domain policy helpers

Install

pip install daylily-auth-cognito

For development in this repo:

source ./activate
pytest -q

activate installs the editable repo and the published cli-core-yo==2.1.1 dependency.

Public API

The top-level package is intentionally small:

from daylily_auth_cognito import (
    CognitoTokenVerifier,
    CognitoWebSessionConfig,
    JWKSCache,
    SessionPrincipal,
    clear_session_principal,
    complete_cognito_callback,
    configure_session_middleware,
    create_auth_dependency,
    load_session_principal,
    start_cognito_login,
    store_session_principal,
    verify_m2m_token_with_jwks,
)

Use submodules directly for admin and CLI-specific work. CLI config handling lives under daylily_auth_cognito.cli.config and is CLI-only.

Runtime Example

from daylily_auth_cognito import CognitoTokenVerifier, create_auth_dependency

verifier = CognitoTokenVerifier(
    region="us-west-2",
    user_pool_id="us-west-2_example",
    app_client_id="client-123",
)

current_principal = create_auth_dependency(verifier)

Browser Session Example

from daylily_auth_cognito import CognitoWebSessionConfig, configure_session_middleware

config = CognitoWebSessionConfig(
    domain="auth.example.test",
    client_id="client-123",
    redirect_uri="https://app.example.test/auth/callback",
    logout_uri="https://app.example.test/logout",
    session_secret_key="replace-me",
    session_cookie_name="app_session",
    public_base_url="https://app.example.test",
    server_instance_id="server-1",
)

configure_session_middleware(app, config)

Hosted UI callbacks exchange the authorization code asynchronously in the web path and only persist normalized principal data in the session. Raw OAuth tokens are rejected.

Set CognitoWebSessionConfig.identity_provider="Google" to select Google explicitly at the Cognito authorize endpoint. The app client must separately restrict its supported providers and password authentication flows. A callback principal resolver can use CognitoTokenVerifier.verify_id_token(token) to require the pool signature/issuer, exact client audience, ID token use, subject and expiry. This method always verifies the signature.

CLI

Activate the repo, then use daycog:

source ./activate
daycog --help
daycog status
daycog auth-config print
daycog setup --help

CLI config remains at ~/.config/daycog/config.yaml.

daycog add-app and daycog edit-app accept --explicit-auth-flows as a nonempty comma-separated list. A Google-only OAuth client uses --idp Google --oauth-flows code --generate-secret --explicit-auth-flows ALLOW_REFRESH_TOKEN_AUTH; restricting displayed providers alone does not disable SDK password authentication. Existing defaults remain unchanged when the explicit-auth-flows option is omitted.

The flat-file config model is implemented in daylily_auth_cognito.cli.config; its internal config helper is not part of the runtime surface.

Layout

daylily_auth_cognito/
  runtime/
  browser/
  admin/
  cli/
  policy/

Docs

Metadata

Release files for daylily-auth-cognito 2.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for daylily-auth-cognito 2.1.7
File Size Uploaded
daylily_auth_cognito-2.1.7.tar.gz 67.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for daylily-auth-cognito 2.1.7
File Interpreter ABI Platform
daylily_auth_cognito-2.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 117.8 kB

Release files / daylily_auth_cognito-2.1.7.tar.gz

Download URL daylily_auth_cognito-2.1.7.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d22fc37191336d1ccd0836d7bf6c0d3da92a631b94bc797be507fdab54c40039
BLAKE2b-256 checksum
How to use checksums
0da979369f0e868bb7d341f2b524a6dfc8355d8c59c97a25219b5272ce55daeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / daylily_auth_cognito-2.1.7-py3-none-any.whl

Download URL daylily_auth_cognito-2.1.7-py3-none-any.whl
Size 50.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bafc34e09d54ac87eabe4c2ea136bd353fe9922722d1f4bfb4253cf588c64b2a
BLAKE2b-256 checksum
How to use checksums
d8bed4c7c13220926f54c8aac49df9c96e720e056b75ffcf0f43f15e905f90f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

2.1.9

2 release files

2.1.8

2 release files

This release

2.1.7 This release

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.0.2

2 release files

2.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page