authentication
Skill2 starsChanged 6 months agoMITView on GitHub
Use when adding sign-in/sign-up or session handling to a SaaS app — set up Auth.js (NextAuth) or a hosted provider with secure sessions, OAuth + email, and server-side session checks that protect routes and actions.
12 other projects use a version of this.
Adopted by
Most recently taken up by
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- jkaninda/okapi-skillstheir own version, first seen Aug 16, 2026
- Kur1sulab/blackboxtheir own version, first seen Aug 12, 2026
- CheehooLabs/SpureeSkillstheir own version, first seen Aug 7, 2026
- codewithmukesh/dotnet-claude-kittheir own version, first seen Jul 22, 2026
- dpearson2699/swift-ios-skillstheir own version, first seen Jul 13, 2026
Used with
Projects with it also use api-security.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
jefflesterSkillapi-security
API security best practices and common vulnerability prevention. Enforces security checks for authentication, input validation, SQL injection, XSS, and OWASP Top 10 vulnerabilities. Use when building or modifying APIs.
Also in 3 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- dpearson2699/swift-ios-skills★ 1.2ksame name
- codewithmukesh/dotnet-claude-kit★ 750same name
- transilienceai/communitytools★ 555same name
- nahid-sparktales/agent-dispatcher★ 59same name
- autosendhq/email-skills★ 18same name
- CheehooLabs/SpureeSkills★ 18same name
- joabgonzalez/ai-agents-skills★ 9same name
- pluginagentmarketplace/custom-plugin-backend★ 4same name
- jkaninda/okapi-skills★ 3same name
- Kur1sulab/blackbox★ 3same name
2 more not listed
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 repository14 other files it gives its agents.
- api-routes-and-validationSkill
- authorization-rbacSkill
- background-jobsSkill
- data-access-layerSkill
- database-schemaSkill
- deployment-and-ciSkill
- environment-and-configSkill
- file-uploads-and-storageSkill
- multi-tenancySkill
- observability-and-errorsSkill
- payments-stripeSkill
- project-scaffoldingSkill
- subscription-billingSkill
- transactional-emailSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Use it in a layout to protect a whole route group:
- Very specific: line 62
Sessions in httpOnly, Secure, SameSite=Lax cookies: Never store tokens in localStorage.
- Distinctive: line 65
Hash passwords with argon2/bcrypt: only if you truly own credentials — prefer OAuth/magic-link.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Authentication
Overview
Authentication is the gate to everything else, so don't hand-roll it. Use Auth.js (NextAuth) with the Drizzle adapter, or a hosted provider (Clerk/Supabase/WorkOS) if you want MFA and user management out of the box. The non-negotiables: httpOnly session cookies, server-side session resolution, and a single requireSession() helper used by every protected route and action.
When to use
- Adding login, signup, OAuth, or magic-link auth.
- Protecting routes, server actions, or route handlers.
- Resolving "who is the current user/org" on the server.
The pattern (Auth.js)
// src/server/auth/index.ts
import "server-only";
import NextAuth from "next-auth";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import Google from "next-auth/providers/google";
import { db } from "@/server/db/client";
import { env } from "@/env";
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: DrizzleAdapter(db),
session: { strategy: "database" },
secret: env.AUTH_SECRET,
providers: [Google],
});// src/server/auth/require.ts
import "server-only";
import { redirect } from "next/navigation";
import { auth } from "@/server/auth";
export async function requireSession() {
const session = await auth();
if (!session?.user) redirect("/sign-in");
return session;
}Use it in a layout to protect a whole route group:
// src/app/(app)/layout.tsx
export default async function AppLayout({ children }) {
await requireSession(); // server-side, runs before render
return <>{children}</>;
}Security essentials
- Sessions in httpOnly, Secure, SameSite=Lax cookies. Never store tokens in
localStorage. - Resolve sessions on the server (
auth()in components/actions), not from a client fetch you trust. - Rotate + expire. Set sensible session max-age; support sign-out everywhere.
- Hash passwords with argon2/bcrypt only if you truly own credentials — prefer OAuth/magic-link.
Pitfalls
- Trusting client-side auth state for authorization — it's a UX hint only; always re-check on the server.
- JWT sessions when you need instant revocation — use the database strategy if "log out all devices" matters.
- Leaking whether an email exists — keep sign-in errors generic (pair with
auth-screensUX). - No CSRF protection on credential posts — Auth.js handles this; don't bypass it with custom forms.
- Protecting only the UI — a route handler without a session check is wide open.
Hand-off
A trustworthy requireSession(). multi-tenancy turns the user into an active org; authorization-rbac checks what that user may do.
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
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.

