agentleFS
RidhuanDEVRidhuanDEV/claude-skills/shadow-auth/SKILL.md

shadow-auth

Skill1 starsChanged yesterdayMITView on GitHub

Identity, AuthN & AuthZ Engineering. Use when implementing or reviewing login, RBAC/ABAC, OAuth2/OIDC, SSO, JWT/session rotation, multi-tenant isolation, or security audit trails.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 2 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill whenever designing, implementing, or modifying login, registration, password reset, MFA, SSO/OAuth2/OIDC, role/permission …

    line 8
  2. Very specific:

    Password Hashing: Always hash passwords with Argon2id (preferred) or bcrypt (cost $\ge 12$).

    line 14
  3. Very specific:

    JWT + Refresh Token Rotation: Keep access tokens short-lived (5–15 minutes).

    line 19
  4. Very specific:

    Prefer fine-grained permissions (invoice:create, invoice:approve, invoice:read:own, invoice:read:tenant) mapped to roles rather than …

    line 29
  5. Very specific:

    Never fetch, update, or delete by primary key id alone (WHERE id = $1).

    line 31
  6. Very specific:

    Always scope queries by the authenticated user's tenant_id / organization_id (WHERE id = $1 AND tenant_id = $2) or enforce PostgreSQL …

    line 32
  7. Very specific:

    Never trust tenant_id, user_id, or role sent in the request body/query if it belongs to the authenticated caller's session context.

    line 33
  8. Distinctive:

    Every privileged or security-sensitive action (login success/failure, password reset, role/permission change, user impersonation, …

    line 39
  9. Very specific:

    Object/Tenant Policy Matrix Tests: Every protected endpoint must include automated negative authorization tests asserting 403/404 for (a) …

    line 51
  10. Distinctive:

    Confused Deputy & Privilege Escalation Prevention: Never derive acting identity or tenant scope from request parameters when an …

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shadow Auth (/shadow-auth) — Identity, RBAC/ABAC, Multi-Tenancy & Session Lifecycle

Use this skill whenever designing, implementing, or modifying login, registration, password reset, MFA, SSO/OAuth2/OIDC, role/permission guards, or multi-tenant data isolation.


1. Authentication & Credential Security Rules (OWASP ASVS V2 & V3)

  1. Password Hashing: Always hash passwords with Argon2id (preferred) or bcrypt (cost $\ge 12$). Never use SHA-256/MD5 or reversible encryption for passwords.
  2. Account Enumeration Prevention: Login, registration, and forgot-password endpoints must return generic user-facing messages and consistent timing so attackers cannot probe valid emails/usernames.
  3. Brute-Force & Credential Stuffing Protection: Enforce rate limiting per IP and per account identifier (e.g., max 5 failed attempts per 15 minutes with progressive lockout or CAPTCHA challenge).
  4. Session & Token Lifecycle:
    • Cookie Sessions / Refresh Tokens: Store in HttpOnly, Secure, SameSite=Lax (or Strict) cookies.
    • JWT + Refresh Token Rotation: Keep access tokens short-lived (5–15 minutes); persist hashed refresh tokens in DB/Redis with a token_family_id so reuse of a rotated refresh token immediately revokes the entire session family.
    • Immediate Revocation: Password change, role downgrade, or account deactivation must immediately invalidate all active sessions/refresh tokens for that user.

2. Authorization Architecture (RBAC, ABAC & Zero-IDOR)

  1. Server-Side Enforcement at Every Entry Point:
    • UI route guards and hidden buttons are for UX only — every API route, GraphQL resolver, server action, and export endpoint MUST enforce both Authentication and Authorization on the server.
  2. Permission Matrix Design (Role -> Permission -> Resource Scope):
    • Prefer fine-grained permissions (invoice:create, invoice:approve, invoice:read:own, invoice:read:tenant) mapped to roles rather than scattering if (user.role === 'ADMIN') checks across controllers.
  3. Strict Multi-Tenant & Ownership Isolation (Anti-IDOR):
    • Never fetch, update, or delete by primary key id alone (WHERE id = $1).
    • Always scope queries by the authenticated user's tenant_id / organization_id (WHERE id = $1 AND tenant_id = $2) or enforce PostgreSQL Row-Level Security (RLS).
    • Never trust tenant_id, user_id, or role sent in the request body/query if it belongs to the authenticated caller's session context.

3. Immutable Security Audit Trail (audit_logs)

Every privileged or security-sensitive action (login success/failure, password reset, role/permission change, user impersonation, approval/rejection, data export, record deletion) MUST write an append-only audit log entry containing:

  • id (UUIDv7 / ULID)
  • timestamp (UTC TIMESTAMPTZ)
  • actor_user_id, actor_role, tenant_id
  • ip_address, user_agent, request_id
  • action (e.g., USER_ROLE_UPDATED, INVOICE_APPROVED)
  • target_entity, target_id
  • before_state & after_state (with secrets/PII redacted)

4. Policy Test Matrix, Confused Deputy & Escalation Gates

  1. Object/Tenant Policy Matrix Tests: Every protected endpoint must include automated negative authorization tests asserting 403/404 for (a) unauthenticated caller, (b) authenticated Tenant A accessing Tenant B object (IDOR/BOLA), and (c) lower-role caller attempting privileged mutation.
  2. Confused Deputy & Privilege Escalation Prevention: Never derive acting identity or tenant scope from request parameters when an authenticated session exists; reject mass-assignment of role, permissions, tenant_id, or is_verified via explicit DTO allowlists.
  3. Revocation Propagation: Session revocation, password rotation, or role downgrade must reject existing access/refresh tokens (and notify active /shadow-realtime connections) within bounded SLA.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.