agentleFS
ViviBeriViviBeri/webcraft-pro/skills/authentication-sessions/SKILL.md

authentication-sessions

Skill11 starsChanged 10 days agoMITView on GitHub

Use when implementing or reviewing login, registration, password reset, MFA, OAuth or OIDC integration, session cookies, token lifecycle, and account recovery.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    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:

    Verify identities safely and maintain sessions with bounded lifetime, protected transport and predictable invalidation.

    line 10
  2. Distinctive:

    Use authorization code flow with PKCE for browser-based public clients.

    line 15
  3. Distinctive:

    Never embed client secrets in browser bundles, mobile packages or public repositories.

    line 16
  4. Distinctive:

    Use MFA or phishing-resistant authentication for privileged and high-risk accounts where supported.

    line 17
  5. Distinctive:

    Use established password hashing implementations with current recommended parameters when passwords must be stored.

    line 19
  6. Distinctive:

    Prefer secure, HttpOnly, appropriately SameSite cookies for browser sessions when the architecture supports them.

    line 24
  7. Distinctive:

    Do not store long-lived bearer tokens in localStorage as a default browser strategy.

    line 30
  8. Distinctive:

    Never log raw passwords, session cookies, access tokens, refresh tokens or recovery secrets.

    line 31
  9. Distinctive:

    Test expired, revoked, replayed and malformed tokens.

    line 39
  10. Distinctive:

    Verify the same for privilege-elevation and account-switch transitions.

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Authentication and Session Security

Objective

Verify identities safely and maintain sessions with bounded lifetime, protected transport and predictable invalidation. Prefer established identity providers and framework security libraries over custom cryptography or token protocols.

Authentication workflow

  1. Select an established identity protocol and provider appropriate to the application. Use OAuth 2.0 for delegated authorization and OpenID Connect when an identity layer is required.
  2. Use authorization code flow with PKCE for browser-based public clients. Validate issuer, audience, signature, expiry, nonce and redirect URI according to the protocol and provider.
  3. Never embed client secrets in browser bundles, mobile packages or public repositories.
  4. Use MFA or phishing-resistant authentication for privileged and high-risk accounts where supported.
  5. Rate-limit login, password reset, verification and recovery operations. Avoid account enumeration through distinguishable responses.
  6. Use established password hashing implementations with current recommended parameters when passwords must be stored. Never store plaintext or reversibly encrypted passwords.
  7. Design recovery flows with short-lived, single-use tokens and explicit user notification for sensitive changes.

Session management

  • Prefer secure, HttpOnly, appropriately SameSite cookies for browser sessions when the architecture supports them.
  • Require HTTPS and set the Secure cookie attribute in production.
  • Regenerate session identifiers after login, privilege changes and other trust transitions.
  • Enforce idle and absolute expiration appropriate to risk.
  • Invalidate sessions on logout, credential reset, account compromise and relevant privilege changes.
  • Protect state-changing cookie-authenticated requests against CSRF.
  • Do not store long-lived bearer tokens in localStorage as a default browser strategy.
  • Never log raw passwords, session cookies, access tokens, refresh tokens or recovery secrets.

OAuth and OIDC checks

Validate redirect URIs exactly, use state for request correlation, use nonce where required, validate PKCE, restrict requested scopes, and protect refresh-token rotation and reuse detection. Do not accept arbitrary return URLs or infer identity from unverified token claims.

Verification

Test expired, revoked, replayed and malformed tokens; session fixation; logout invalidation; CSRF; brute-force controls; MFA recovery; account enumeration; and privilege changes. Include negative tests for invalid issuer, audience, signature and redirect URI.

Completion criteria

Identity protocol validation is correct, sessions are protected and revocable, recovery and MFA flows resist abuse, and secrets are absent from client code and logs.

Common AI failure mode

Failure: An agent implements login successfully but reuses the pre-authentication session identifier after login, and at privilege or trust transitions (elevation, account switch, MFA completion).

Why it matters: An attacker who can fix or pre-seed a session identifier inherits the authenticated identity of the victim after login. The compromise survives the login boundary and persists across privileged actions and account data, even though the login flow itself appears to work.

Prevention: Regenerate the session identifier at authentication and at every privilege or trust transition; invalidate the prior identifier server-side after rotation. Set idle and absolute expiry, and revoke the session on logout and on credential or security events. Test fixation by establishing a pre-login session, completing login, and proving the pre-login identifier cannot authenticate any privileged request after that point. Verify the same for privilege-elevation and account-switch transitions.

Token storage and exposure (localStorage, URLs, logs, analytics, error reports, telemetry) is a related but distinct failure mode — see secrets-configuration.

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.