Skip to content

🦊🔥 Chonky GitRitual: Admin Token System & Auth Hardening#14

Merged
AdaInTheLab merged 1 commit intomainfrom
refactor/admin-auth-what-a-journey
Jan 6, 2026
Merged

🦊🔥 Chonky GitRitual: Admin Token System & Auth Hardening#14
AdaInTheLab merged 1 commit intomainfrom
refactor/admin-auth-what-a-journey

Conversation

@AdaInTheLab
Copy link
Owner

This PR marks the completion of a full security foundation pass across admin auth, API tokens, and test infrastructure.

What started as “just add tokens” evolved (correctly) into a deeper systems ritual: tightening contracts, removing ambiguity, and making the backend boring in the best possible way.


✨ What This PR Does

🔐 Admin Token System

  • Introduces secure API token minting and revocation
  • Raw tokens are returned once and never stored
  • Tokens are hashed with a pepper (fail-closed in production)
  • Token listing never leaks secrets
  • Revocation is idempotent and explicit

🛡️ Admin Auth Hardening

  • Clarifies requireAdmin behavior (401 vs 403, bypass rules)
  • Ensures deterministic failure modes
  • Aligns middleware behavior with route expectations

🧪 Test Infrastructure & Coverage

  • Adds Jest coverage for:
    • token minting / verification
    • admin token routes
    • auth middleware behavior
  • Aligns tests with real API response shapes ({ ok, data })
  • Prevents future regressions around auth + security flows
  • Ignores generated coverage artifacts (coverage/)

🧱 API Contract Stabilization

  • Normalizes status codes:
    • POST /admin/tokens → creates a resource
    • GET /admin/tokens → lists existing resources
    • POST /admin/tokens/:id/revoke → mutates existing state
  • Removes ambiguity between implementation and tests

🧠 Why This Matters

This PR establishes a stable, test-backed security layer that future work can safely build on:

  • CLI access
  • Agent workflows
  • Scoped permissions
  • Automation & CI integrations

No haunted state.
No vibes-based auth.
No “why did this work yesterday?” energy.


🦝 Ritual Notes

  • This was intentionally done as one cohesive change
  • The system is now boring, predictable, and extensible
  • Future work should build on top of this, not around it

Ritual complete. Chonk honored.

co-authored-by: Lyric lyric@thehumanpatternlab.com
co-authored-by: Carmel carmel@thehumanpatternlab.com

…bilization 🧱🔐

- Add secure API token minting + revocation
- Enforce hashed token storage with pepper
- Normalize admin auth behavior (bypass, allowlists, failure modes)
- Align admin token API responses and status codes
- Add Jest coverage for tokens, admin routes, and middleware
- Ignore generated coverage artifacts

This establishes a stable security foundation for future CLI and agent access.

co-authored-by: Lyric <lyric@thehumanpatternlab.com>
co-authored-by: Carmel <carmel@thehumanpatternlab.com>
@AdaInTheLab AdaInTheLab merged commit 2302a57 into main Jan 6, 2026
1 check passed
@AdaInTheLab AdaInTheLab deleted the refactor/admin-auth-what-a-journey branch January 6, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant