auth-security
Skill65 starsChanged 3 months agoMITView on GitHub
Secure authentication and authorization when credentials, sessions, roles, or permissions change.
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Classification: ALL classifications that touch auth, permissions, user data, or session management
- Distinctive: line 55
NEVER store plaintext passwords — not even in logs, not even temporarily
- Distinctive: line 57
Check against breach database (HaveIBeenPwned API) on registration if feasible
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.
Files
<!-- This is a SCAFFOLD skill -->Auth & Security
When to Apply
- Classification: ALL classifications that touch auth, permissions, user data, or session management
- Phase: /plan (auth flow design), /implement (auth logic), /review (MANDATORY for any auth-related change), /test (auth bypass testing)
- Trigger: Task involves login, registration, password, token, session, role, permission, or access control
Relationship to Security Guardrails
This skill extends .agent/rules/security_guardrails.md with APP-specific auth patterns. The security guardrails handle OWASP scanning and secret detection. This skill handles auth architecture and implementation patterns.
Precedence: security_guardrails.md > this skill. If conflict, security guardrails win.
Conventions
Customize after /app-init: Replace these with your project's ADR auth decisions.
Authentication Flow (JWT Example)
Client Server DB
|-- POST /auth/login -->| |
| {email, password} |-- verify password hash -->|
| |<-- user record -----------|
|<-- {access_token, | |
| refresh_token} ---| |
| | |
|-- GET /api/resource ->| |
| Authorization: |-- verify token |
| Bearer <access> |-- check permissions |
|<-- 200 data ---------| |
| | |
|-- POST /auth/refresh->| |
| {refresh_token} |-- verify + rotate ------->|
|<-- {new_access, |<-- new tokens ------------|
| new_refresh} -----| |Token Rules
- Access token: Short-lived (15-30 min). Stored in memory only (NOT localStorage).
- Refresh token: Longer-lived (7-30 days). Stored in httpOnly, secure, sameSite cookie.
- Token rotation: Issue new refresh token on each refresh. Invalidate old one.
- Revocation: Maintain a blocklist for compromised tokens (or use short expiry + DB check).
Password Rules
- Hash with bcrypt (cost 12+) or argon2id
- NEVER store plaintext passwords — not even in logs, not even temporarily
- Minimum 8 characters, no maximum less than 128
- Check against breach database (HaveIBeenPwned API) on registration if feasible
- Rate limit login attempts: 5 failures → temporary lockout (progressive delay)
Authorization (RBAC Pattern)
Users ──< UserRoles >── Roles ──< RolePermissions >── Permissions| Concept | Example | Storage |
| Role | admin, editor, viewer | roles table |
| Permission | users:read, users:write, posts:delete | permissions table |
| Assignment | User A has role "editor" | user_roles junction table |
Middleware pattern (pseudocode):
authenticate(req) → verify token, attach user to request
authorize('posts:write') → check user's roles have this permission
handler(req, res) → business logic (user is authenticated + authorized)Session Security
- Set
httpOnly,secure,sameSite=stricton auth cookies - Regenerate session ID after login (prevent session fixation)
- Invalidate all sessions on password change
- Implement "logout everywhere" for compromised accounts
Input Security (Auth-Specific)
- Sanitize email: lowercase, trim, validate format
- Timing-safe comparison for tokens and passwords (prevent timing attacks)
- Generic error messages: "Invalid email or password" (never reveal which one is wrong)
- CAPTCHA or rate limiting on registration and login endpoints
Checklist
During /plan:
- Auth flow documented in spec (which endpoints, which tokens, which storage)
- Permission model defined (who can do what)
- Session management strategy chosen (per ADR)
During /implement:
- Passwords hashed with approved algorithm (bcrypt/argon2, NOT MD5/SHA1)
- Tokens validated on EVERY protected endpoint (no missing auth middleware)
- Refresh token rotation implemented
- Rate limiting on auth endpoints
- No sensitive data in JWT payload (no password, no PII beyond user ID)
- CORS configured to restrict origins
During /review:
- No auth bypass paths (every protected route checked)
- No hardcoded credentials or API keys
- Error messages don't leak user existence (registration: "If this email exists...")
- Password reset token is single-use and time-limited
- Admin endpoints have role check (not just auth check)
During /test:
- Test: unauthenticated request → 401
- Test: wrong role → 403
- Test: expired token → 401
- Test: manipulated token (wrong signature) → 401
- Test: rate limit triggers after N failures
- Test: password change invalidates old tokens
Heading-Scoped Read Note
For phase-entry loading, read only:
When to ApplyRelationship to Security GuardrailsChecklist
Load Conventions, Anti-Patterns, and References on full read or cache miss only.
Anti-Patterns
- JWT in localStorage: Vulnerable to XSS. Use httpOnly cookies or in-memory only.
- No refresh token rotation: Stolen refresh token = permanent access. Always rotate.
- Role check in frontend only: Frontend hides UI but backend doesn't enforce. ALWAYS check server-side.
- Password in logs: Logging request body that includes password field. Exclude sensitive fields.
- Shared admin token: One API key for all admin operations. Use per-user auth with audit trail.
- No rate limiting: Brute force attacks on login become trivial.
- Email enumeration: "No account with this email" on login. Use generic "Invalid credentials".
- Long-lived access tokens: Access tokens valid for days. Use short-lived + refresh pattern.
- Missing CSRF protection: For cookie-based auth, CSRF tokens are mandatory on state-changing requests.
References
- Project ADR:
docs/adr/ADR-002-project-architecture.md§ Auth & Security - Security guardrails:
.agent/rules/security_guardrails.md(A01, A02, A07 — primary references) - Red team skill:
.agents/skills/red-team-adversarial/SKILL.md(auth bypass testing) - Spec template:
.agentcortex/templates/spec-app-feature.md§ Auth & Permissions
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- KbWen/agentic-os★ 22499% same
Wrote their own version · 2
- nahid-sparktales/agent-dispatcher★ 59same name
- YepAPI/skills★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- api-designSkill
- database-designSkill
- dispatching-parallel-agentsSkill
- doc-lookupSkill
- frontend-patternsSkill
- karpathy-principlesSkill
- production-readinessSkill
- red-team-adversarialSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- using-git-worktreesSkill
- verification-before-completionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

