agentleFS
pabloirracionalpabloirracional/claude-skills/skills/adding-authentication/SKILL.md

adding-authentication

Skill0 starsChanged 4 months agoMITView on GitHub

Adds token-based authentication to an app, with 5 real attack scenarios (tampering, expiry, wrong secret, algorithm confusion) tested against actual JWT code to confirm what's actually safe. Use whenever the user wants to add login, signup, or authentication to an app, or mentions JWTs, sessions, Auth0, or protected routes.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never store tokens in localStorage for anything sensitive: - prefer httpOnly cookies where the framework supports it, to reduce XSS …

    line 14
  2. Distinctive:

    If multi-factor auth or social login is needed, confirm which providers before scaffolding - each addition usually needs separate …

    line 40

≈ “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

Adding authentication

Adds token-based authentication, verified against 5 real attack scenarios run against actual signing/verification code - not just "JWTs are secure if implemented correctly" as an unverified claim.

Workflow

  1. Detect the framework first - the SDK and setup pattern differ across Next.js, React SPA, Express API, or mobile.
  2. Decide session model: server-side session vs client-held JWT - state the trade-off (revocation ease vs statelessness) rather than picking silently.
  3. Never store tokens in localStorage for anything sensitive - prefer httpOnly cookies where the framework supports it, to reduce XSS exposure.
  4. Pin the algorithm explicitly when verifying - see the tested attack below, this is the one mistake that turns a correct-looking JWT setup into a real vulnerability.
  5. Test the logout/expiry path explicitly - session invalidation is frequently untested.

Tested: 5 real attacks against a working JWT implementation

Ran with the real jsonwebtoken npm package, not simulated:

#AttackResult
1Valid token, normal verificationPASS - verified correctly, payload intact
2Payload tampered after signing (role changed to admin, signature not redone)PASS - rejected: invalid signature
3Expired token (expiresIn: '-1s')PASS - rejected: jwt expired
4Token forged with the wrong secretPASS - rejected: invalid signature
5"alg": "none" token (classic JWT library vulnerability)PASS - rejected: jwt signature is required

All 5 held using the library's default verification settings. The important caveat from test 5: this only holds because the code never explicitly allows algorithms: ['none'] or omits algorithm pinning in a custom verifier. Some JWT libraries (and hand-rolled verifiers) historically accepted alg: none if the caller didn't restrict allowed algorithms - always verify with an explicit algorithms: ['HS256'] (or whichever is actually used) rather than trusting library defaults blindly, since defaults have changed across versions and libraries.

// Explicit is safer than implicit, even though the default passed the test above:
jwt.verify(token, SECRET, { algorithms: ['HS256'] });

Notes

  • Test 2 (tampering) is the one people most often assume "obviously works" without checking - it does, but only because the signature covers the full payload. If a custom implementation ever splits signing from the full payload (e.g. signs a hash but ships extra unsigned fields the app trusts), this protection silently breaks.
  • If multi-factor auth or social login is needed, confirm which providers before scaffolding - each addition usually needs separate configuration in the auth provider's dashboard.
  • Server-side verification is non-negotiable for anything with real access control - never trust a client-supplied claim (including a decoded-but-unverified JWT payload) without running it through verify().

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.