auth-authorization
Skill2 starsChanged 4 months agoMITView on GitHub
Implement authentication (login, session/JWT, OAuth, magic links) and authorization (roles, permissions, route protection) in full-stack React/Next.js apps. Use whenever the user asks about login, sign-up, sessions, JWT, OAuth providers, protecting routes, role-based access control, or "who can see/do what" in the app.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- Adhamxon/claude-code-skillstheir own version, first seen Jul 30, 2026
- batur/ts-baseline-docstheir own version, first seen Jul 29, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Adhamxon/claude-code-skills★ 2same name
- batur/ts-baseline-docs★ 1same 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 repository22 other files it gives its agents.
- accessibility-a11ySkill
- design-system-tailwindSkill
- motion-design-toolkitSkill
- nextjs-architectureSkill
- react-component-engineeringSkill
- react-three-fiber-3dSkill
- responsive-mobile-firstSkill
- database-schema-designSkill
- form-validation-error-handlingSkill
- mern-stack-architectureSkill
- rest-api-integrationSkill
- state-managementSkill
- landing-page-conversionSkill
- payment-gateway-integrationSkill
- saas-dashboard-adminSkill
- startup-mvp-developmentSkill
- ux-research-flow-designSkill
- visual-design-languageSkill
- ai-assisted-frontend-workflowSkill
- deployment-vercel-productionSkill
- performance-seo-optimizationSkill
- project-architecture-clean-codeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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 13
If JWTs are required (e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Authentication & Authorization Skill
Authentication: prefer a managed/battle-tested library over hand-rolled
Default recommendation for Next.js: Auth.js (NextAuth), Clerk, or Better Auth — hand-rolling password hashing, session handling, and OAuth flows is a security liability unless there's a specific reason to. If the user insists on custom auth, still use vetted primitives (bcrypt/argon2 for hashing, jose for JWT) and never invent your own crypto.
Session strategy
- Cookie-based sessions (httpOnly, secure, sameSite=lax/strict) are the default for web apps — not localStorage-stored JWTs, which are vulnerable to XSS token theft.
- If JWTs are required (e.g. for a separate API consumed by mobile), keep them short-lived (~15 min) with a refresh token rotated and stored httpOnly, not in localStorage/sessionStorage.
- Validate the session on the server on every protected request — never trust a client-supplied "isLoggedIn" flag.
Route protection (Next.js App Router)
// middleware.ts
export function middleware(req: NextRequest) {
const session = getSessionFromCookie(req);
if (!session && isProtectedRoute(req.nextUrl.pathname)) {
return NextResponse.redirect(new URL('/login', req.url));
}
}
export const config = { matcher: ['/dashboard/:path*', '/settings/:path*'] };Also re-check auth inside the Server Component/Server Action itself (defense in depth) — middleware alone isn't a substitute for checking session before returning sensitive data.
Authorization (RBAC/permissions)
- Model as
role(coarse: admin/member/viewer) + optional fine-grainedpermissionsarray for anything beyond simple role tiers. - Enforce authorization at the data-access layer (inside the service function that queries the DB), not only in the UI — hiding a button is not access control.
async function getOrgSettings(userId: string, orgId: string) {
const membership = await getMembership(userId, orgId);
if (!membership || membership.role !== 'admin') throw new ForbiddenError();
return db.orgSettings.findUnique({ where: { orgId } });
}- For multi-tenant apps, scope every query by
orgId/tenantIdderived from the session — never trust a tenant ID passed from the client without cross-checking membership.
OAuth integration checklist
- Redirect URIs registered exactly (including protocol/trailing slash) per environment (dev/staging/prod)
- State parameter validated to prevent CSRF on the OAuth callback
- Minimum necessary scopes requested
- Provider-returned email verified/trusted only if the provider confirms email verification
Anti-patterns to flag
- JWTs or session tokens stored in
localStorage - Authorization checks only in the frontend (hiding UI ≠ securing data)
- Password hashing with plain SHA-256/MD5 instead of bcrypt/argon2
- Missing tenant/org scoping on a query in a multi-tenant app (cross-tenant data leak)
Example prompt this skill should trigger on
"Add login with email/password and Google OAuth, and make sure only admins can access the billing settings page."
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.

