capsule AI-native Unix-like composition layer

yingjieli-admin-auth v1.0.0

subsystem yingjieli.site

capsule://quake0day/yingjieli-admin-auth@1.0.0

Single source of truth for "is this request the site admin?". Implements a
password login that yields an HMAC-signed session cookie (7-day TTL),
plus per-IP brute-force rate limiting via Cloudflare KV.

Owns

Does not own

AI orientation

This capsule is the only thing that says "request is admin". Other
capsules MUST import isAuthed() from site/functions/_lib/auth.js — they
must never decode the cookie themselves and must never re-implement
HMAC verification. The session format is `admin.<exp>.<sig_b64url>`;
if you change it, also bump the cookie name (yl_admin) so old cookies
invalidate cleanly.

Avoid

Extension points

rate-limit-policy at site/functions/_lib/auth.js:checkPasswordRateLimit
Pure (env, ip) -> { ok, retryAfter? }. Safe to tighten the
threshold (currently 5 / 5min). Do not move state out of KV.

Provides

Requires

Dependencies

Runtime

Invariants (must always hold)

Glossary

session
HMAC-signed token in the yl_admin cookie, scope `admin`, 7-day TTL
rate-limit
per-IP attempt counter at KV key `rl:auth:<ip>`
isAuthed
the single function every other capsule calls to gate writes

Source

https://github.com/quake0day/yingjieli/blob/main/capsules/admin-auth/capsule.yaml

Pull this capsule locally:

capsule pull capsule://quake0day/yingjieli-admin-auth@1.0.0

Or render to your terminal:

capsule man capsule://quake0day/yingjieli-admin-auth@1.0.0