Skip to main content

Auto-rotating secret generation with Argon2 hashing and scheduled SMTP delivery

Project description

scheduled-email

Auto-rotating secret generation — creates Argon2-hashed secrets and delivers password-less login links via SMTP on a configurable schedule.

Install

pip install scheduled-email

尚未发布到 PyPI 前,需先按 PUBLISH.md 完成上传。 本地开发可用 editable 模式:pip install -e packages/scheduled-email

Environment Variables

Variable Required Default Description
SCHEDMAIL_SMTP_USER yes Sender email address
SCHEDMAIL_SMTP_PASS yes SMTP authorization code
SCHEDMAIL_RECIPIENT yes Recipient email address
SCHEDMAIL_BASE_URL no https://example.com/login?token= Prefix for login URL
SCHEDMAIL_ROTATE_HOURS no 24 Rotation interval (hours)
SCHEDMAIL_SCT no *****-daiju SCT constant
SCHEDMAIL_MASK_SECRET no false Mask secret in email body

Copy .env.example to .env and fill in credentials. Never commit .env.

Usage

Standalone

from scheduled_email import start, stop

svc = start()       # immediate first rotation + email, then every 24h
# ...
stop()               # cancel timer

Context Manager

from scheduled_email import ScheduledEmailService

with ScheduledEmailService() as svc:
    print(svc.current_url)

FastAPI Integration (minimal)

from contextlib import asynccontextmanager
from fastapi import FastAPI

@asynccontextmanager
async def lifespan(app: FastAPI):
    from scheduled_email import start, stop
    start()
    yield
    stop()

app = FastAPI(lifespan=lifespan)

How It Works

  1. On start(), a 32-byte random secret is generated via secrets.token_urlsafe.
  2. The secret is hashed with Argon2 (argon2-cffi).
  3. A login URL is built: {SCHEDMAIL_BASE_URL}{argon2_hash}.
  4. An email is sent via SMTP_SSL containing: rotation time, SCT, secret (optionally masked), and the full login URL.
  5. A threading.Timer schedules the next rotation after SCHEDMAIL_ROTATE_HOURS.

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

scheduled_email-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

scheduled_email-0.1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file scheduled_email-0.1.1.tar.gz.

File metadata

  • Download URL: scheduled_email-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for scheduled_email-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a099c5ca9331f6a6f20011348eeeda53bfcdbd15b819da12f92115cb4c68721e
MD5 8168b5ba792a8fe0963e334c7706eb82
BLAKE2b-256 eb73f2f1b68bc24c4bfd94c2850d8d2736806dbe14a5f3933a385fd9e68472c6

See more details on using hashes here.

File details

Details for the file scheduled_email-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scheduled_email-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08466b617cdff69dc9b76ebaa522cf109dbf5e23c54abdbf90f864b7a9eceed2
MD5 4625c31ac2723275ccab42832ddc0bec
BLAKE2b-256 8cbb31d30daac11a621f829da75344e47a576749539538e0e2634ef29f083b24

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