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
- On
start(), a 32-byte random secret is generated viasecrets.token_urlsafe. - The secret is hashed with Argon2 (
argon2-cffi). - A login URL is built:
{SCHEDMAIL_BASE_URL}{argon2_hash}. - An email is sent via SMTP_SSL containing: rotation time, SCT, secret (optionally masked), and the full login URL.
- A
threading.Timerschedules the next rotation afterSCHEDMAIL_ROTATE_HOURS.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scheduled_email-0.1.0.tar.gz.
File metadata
- Download URL: scheduled_email-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
172ec0506334782b56725b1202467ec6972a326172c596045cec3ceec5737b6f
|
|
| MD5 |
b050041c9d5bbd092571eed14174a82e
|
|
| BLAKE2b-256 |
75518de11de06683f077b7efe155c20526041d5a4a409f1901e416fe6d795164
|
File details
Details for the file scheduled_email-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scheduled_email-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c2bfcfe1c4c699a57781683251ff5b3746bcde3acfc910c6bac99ec87f5321e
|
|
| MD5 |
7aba8c1a888cea46cc42e3028e597e41
|
|
| BLAKE2b-256 |
fe2abacaf2e51f39e17ea11317b2e6f1eb1abd1947631f97608b8d19b915d99f
|