authentication-patterns

A reference for choosing and implementing user authentication, which is how an application confirms who someone is. It compares sessions, JWTs, OAuth 2.0/OIDC, and passkeys.

In plain words
What is it for?
Use it when building or reviewing login flows, selecting an authentication provider, or moving between authentication strategies. It includes comparisons and a security checklist for auth-related changes.
Why use it?
It helps match an authentication method to the application while avoiding common security mistakes. It also explains trade-offs such as revocation, server-side storage, external providers, and passwordless access.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zebbern/claude-code-guide/authentication-patterns
Any agent
npx skills add zebbern/claude-code-guide --skill authentication-patterns
Clone the repo
git clone --depth 1 https://github.com/zebbern/claude-code-guide

Made for: Claude Code, Codex.

Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,894 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00047 $0.01894
Opus 5 $0.00023 $0.00947
Sonnet 5 $0.00009 $0.00379
Haiku 4.5 $0.00005 $0.00189

Measured yesterday against content hash 4c26152037ad, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

authentication-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/authentication-patterns/SKILL.md · 167 lines

How it starts

The opening of the file, as written. The whole thing — 167 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Authentication Patterns Skill

Reference for implementing secure, production-ready authentication.

WHEN_TO_USE

Apply this skill when implementing authentication in a project, reviewing existing auth flows for security issues, choosing between auth providers, or migrating between auth strategies. Use the security checklist before shipping any auth-related change.

AUTH_APPROACHES

Approach How It Works Best For Drawbacks
Session-based Server stores session in DB/Redis, client holds session ID cookie Traditional server-rendered apps, apps needing instant revocation Requires server-side storage, harder to scale horizontally without shared store
JWT (stateless) Server signs token, client sends it on each request API-first apps, microservices, mobile clients Cannot revoke without blocklist, token size grows with claims
OAuth 2.0 / OIDC Delegates auth to external provider (Google, GitHub, etc.) Social login, enterprise SSO, reducing auth responsibility More complex flow, depends on external provider availability
Passkeys / WebAuthn Cryptographic key pair, no passwords High-security apps, passwordless UX Limited browser support legacy, user education needed

Decision Guide

  • Server-rendered app with simple needs → Session-based
  • SPA or mobile app calling APIs → JWT with refresh token rotation
  • Want social login or SSO → OAuth 2.0 / OIDC
  • Greenfield with modern UX goals → Passkeys + OAuth fallback

JWT_BEST_PRACTICES

Token Lifecycle

Login → Access Token (short-lived) + Refresh Token (long-lived, rotated)
  │
  ├─ Access Token: 15 min expiry, sent via httpOnly cookie or Authorization header
  │
  └─ Refresh Token: 7-30 day expiry, stored in httpOnly secure cookie
       │
       └─ On use: issue new access + new refresh token, invalidate old refresh token

Rules

  • [P0-MUST] Set short expiry on access tokens (15 minutes or less).
  • [P0-MUST] Store tokens in httpOnly, Secure, SameSite=Lax cookies — never in localStorage or sessionStorage.
  • [P0-MUST] Implement refresh token rotation — each refresh token is single-use.
  • [P0-MUST] Maintain a server-side blocklist for revoked refresh tokens.
  • [P1-SHOULD] Include only essential claims in JWT payload (sub, iat, exp, role). Keep it small.
  • [P1-SHOULD] Use asymmetric signing (RS256 or ES256) for distributed systems; symmetric (HS256) for single-service only.
  • [P1-SHOULD] Validate iss, aud, and exp claims on every request.
  • [P2-MAY] Use JWE (encrypted JWT) when token payload contains sensitive data.

Read the full file on GitHub · 167 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 167 lines · 47 tokens per session scan A 4c26152037ad

Subscribe to this mod's changes

authentication-patterns is a skill published in the GitHub repository zebbern/claude-code-guide (4,596 stars, last pushed 3d ago), licensed MIT. It adds 47 tokens to every session and 1,894 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

cdb-scan

Map this codebase into project memory — a code graph of every symbol and how they connect, plus a written profile of stack, layout, conventions and workflows. Re-run any time to refresh both in place. Use when memory is newly installed on an existing project, or when the project has changed enough that the stored map…

Avijit07x/claude-db · 72 tokens

mckinsey-consultant

McKinsey顾问式问题解决系统。从商业问题出发,通过假设驱动的结构化分析方法,生成McKinsey风格研究报告和PPT。融合Problem Solving方法论、MECE原则、Issue Tree拆解、Hypotheses形成、Dummy Page设计、智能数据收集和专业PPT生成能力。.

Mann1988/awesome-claude-skills · 82 tokens

exam-coach

Quiz and coach the user for the Anthropic Claude certification exams using this repository's blueprints and official exam guides. Use when the user asks to practice, be quizzed, drill a domain, take a mock exam, or prepare for the Associate, Developer, or Architect certifications.

Amey-Thakur/CLAUDE-CERTIFICATIONS · 61 tokens

security-claude

Skill "security-claude" from rahozosman/security-claude, covering security architecture & threat modeling intelligence, how this skill is organized (progressive disclosure), 1. pick a mode, 2. core method (applies to every mode) and 3. doing a focused review.

rahozosman/security-claude · 0 tokens

bridger

Coordinate with another Claude Code session over the bridge — discover peers, ask them, answer their questions — INSTEAD of guessing or asking the user. Trigger this the moment the task depends on something another repo's session knows: a dependency/library that changed and this code consumes it, an API or schema…

HoussemDjeghri/bridger · 131 tokens

run-tests

Run the pytest suite, report pass/fail counts and coverage, and identify untested code. Use when the user asks to run tests, check test coverage, or verify that changes didn't break anything.

JSchOBL/agentic-ai-learning-journey · 43 tokens