authentication-identity-expert
Skill129 starsChanged 13 days agoMITView on GitHub
Authentication, authorization (RBAC/ABAC), OAuth2, Clerk, and Auth.js / Autentikasi, otorisasi (RBAC/ABAC), OAuth2, Clerk, dan Auth.js.
- Reads credentials
In this repository372 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/vibes-plug-anti-slop.mdcCursor rule
- .cursor/rules/vibes-plug-backend.mdcCursor rule
- .cursor/rules/vibes-plug-core.mdcCursor rule
- .cursor/rules/vibes-plug-devops.mdcCursor rule
- .cursor/rules/vibes-plug-frontend.mdcCursor rule
- .cursor/rules/vibes-plug-mcp.mdcCursor rule
- .cursor/rules/vibes-plug-skills.mdcCursor rule
- .cursor/rules/vibes-plug-testing.mdcCursor rule
- llms-full.txtllms.txt
- llms.txtllms.txt
- showcase/llms-full.txtllms.txt
- showcase/llms.txtllms.txt
- a2a-agent-protocol-expertSkill
- accessibility-testing-expertSkill
- adaptive-model-cascadeSkill
- affective-computing-emotion-aiSkill
- agentic-coding-workflow-expertSkill
- agentic-m2m-settlementSkill
- agentic-memory-architectSkill
- agentic-micro-economy-architectSkill
- ai-code-review-autonomousSkill
- ai-llm-integration-expertSkill
- ai-media-generation-expertSkill
- ai-prompt-engineering-expertSkill
- ai-safety-governance-expertSkill
- angular-expertSkill
- anti-slopSkill
- api-design-expertSkill
- api-gateway-proxy-expertSkill
- app-analyzer-optimizerSkill
- apple-ecosystem-expertSkill
- app-promo-media-expertSkill
- astro-framework-expertSkill
- async-queue-temporal-expertSkill
- autonomous-api-drift-healerSkill
- autonomous-red-teamerSkill
- autonomous-tdd-debuggerSkill
- biome-linter-formatter-expertSkill
- blockchain-web3-expertSkill
- brainstormingSkill
- browser-automation-expertSkill
- browser-extension-mv3-proSkill
- bun-runtime-expertSkill
- chatbot-messaging-expertSkill
- ci-cd-devops-architectSkill
- cloudflare-workers-expertSkill
- cloud-hosting-expertSkill
- coderabbitSkill
- compliance-gdpr-privacy-expertSkill
- composable-mach-architectSkill
- computer-use-os-agent-expertSkill
- context-window-engineerSkill
- cron-scheduler-expertSkill
- database-orm-expertSkill
- data-pipeline-etl-expertSkill
- data-telemetry-expertSkill
- data-visualization-expertSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 165
Mandatory Blue-Ocean Pairing: Always compose authentication-identity-expert with autonomous-tdd-debugger, autonomous-red-teamer, …
- Very specific: line 167
Pre-Disk Gate: Run vibes verify-gate and vibes skill auto-diff --json to inject <350-token slices and eliminate placeholder slop.
≈ “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.
Files
Authentication & Identity Expert (2026 Edition)
English | Bahasa Indonesia
<a name="english"></a>
English
Orchestration & Integration
- Upstream Orchestrators: Works under
brainstormingandzero-to-prod-orchestrator(Phase 2 - Foundation, Auth & Identity Architecture) to implement secure user authentication. - Downstream Cooperating Skills:
compliance-gdpr-privacy-expert— Mandatory account deletion flow, crypto-shredding, and UU PDP / GDPR right to erasure.saas-architect— B2B multi-tenant auth workflows, organization switching, and onboarding.saas-multi-tenant— RBAC permission matrices, custom session claims, and workspace member access.supabase-security-expert— Supabase SSR auth, PKCE token cookies, and RLS policies.firebase-security-expert— Firebase Auth, custom token minting, and security rules.js-backend-expert— Authorization middleware, JWT token verification, and session stores.production-ready-hardener— Pre-release auth security audits, rate-limiting, and CSP headers.session-memory-manager— Store authentication topology decisions and credential schemas.
Description
Production-grade guide for implementing secure authentication, authorization, and identity management in modern web and mobile applications. Covers Clerk, Supabase Auth, Auth.js v5, Better Auth, JWT patterns, OAuth 2.1, PKCE flows, RBAC/ABAC, passkeys (WebAuthn), and MFA implementations for React 19 / Next.js 16 stacks.
Trigger Conditions
- Working on login/signup flows, session management, or OAuth integrations.
- Integrating Clerk, Supabase Auth, Auth.js v5, Better Auth, or Auth0.
- Implementing RBAC (Role-Based Access Control) or ABAC.
- Setting up WebAuthn/Passkeys, MFA/2FA, or SSO.
- Securing Next.js App Router routes with middleware-based auth guards.
- Implementing mandatory self-service account deletion and user data deletion lifecycle.
Identity Provider Selection Guide
| Provider | Best For | Key Strength | Pricing Model |
| Clerk | New SaaS products | Best developer DX, prebuilt UI components, orgs/teams out-of-the-box | Per MAU (free up to 10k) |
| Supabase Auth | Existing Supabase apps | Native RLS integration, multi-provider OAuth, generous free tier | Included with Supabase |
| Auth.js v5 | Self-hosted control | Full data ownership, zero vendor lock-in, Edge-compatible | 100% Free / OSS |
| Better Auth | Modern TS-first apps | Comprehensive TypeScript plugin ecosystem, 2FA, passkeys | 100% Free / OSS |
Technical Guidelines & Recipes
1. Password Hashing Standards
import argon2 from 'argon2';
export async function hashPassword(password: string): Promise<string> {
return argon2.hash(password, {
type: argon2.argon2id,
memoryCost: 65536, // 64 MB
timeCost: 3,
parallelism: 4,
});
}2. Short-Lived JWT + Refresh Token Rotation
// Access token: 15 minutes, in memory
// Refresh token: 7-30 days, HttpOnly, Secure, SameSite=Strict cookie3. OAuth 2.1 + PKCE
import { generateCodeVerifier, generateCodeChallenge } from 'oslo/oauth2';
const codeVerifier = generateCodeVerifier();
const codeChallenge = await generateCodeChallenge(codeVerifier);
sessionStorage.setItem('pkce_verifier', codeVerifier);
const authUrl = new URL('https://provider.com/oauth/authorize');
authUrl.searchParams.set('code_challenge', codeChallenge);
authUrl.searchParams.set('code_challenge_method', 'S256');
authUrl.searchParams.set('state', cryptoRandomState);4. Clerk — Next.js 16 Integration
// middleware.ts
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
const isPublicRoute = createRouteMatcher(['/', '/sign-in(.*)', '/sign-up(.*)', '/api/webhooks(.*)']);
export default clerkMiddleware(async (auth, req) => {
if (!isPublicRoute(req)) await auth.protect();
});
export const config = {
matcher: ['/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)', '/(api|trpc)(.*)'],
};5. Supabase Auth — RLS Integration
For detailed Supabase Auth SSR setup, PKCE session cookie handling, and PostgreSQL Row-Level Security (RLS) policies, delegate directly to
supabase-security-expert.
6. Auth.js v5 (Next.js App Router)
import NextAuth from 'next-auth';
import GitHub from 'next-auth/providers/github';
import { DrizzleAdapter } from '@auth/drizzle-adapter';
import { db } from '@/db';
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: DrizzleAdapter(db),
providers: [GitHub],
session: { strategy: 'database' },
});7. RBAC — Role-Based Access Control (Server-Side)
type Role = 'viewer' | 'editor' | 'admin' | 'super_admin';
const permissions: Record<Role, string[]> = {
viewer: ['read:posts'],
editor: ['read:posts', 'write:posts', 'delete:own_posts'],
admin: ['read:posts', 'write:posts', 'delete:any_post', 'manage:users'],
super_admin: ['*'],
};
export function hasPermission(userRole: Role, required: string): boolean {
const allowed = permissions[userRole] || [];
return allowed.includes('*') || allowed.includes(required);
}8. WebAuthn / Passkeys (2026 Standard)
import { generateRegistrationOptions, verifyRegistrationResponse } from '@simplewebauthn/server';
export async function getPasskeyRegistrationOptions(userId: string, userEmail: string) {
return generateRegistrationOptions({
rpName: 'My App',
rpID: 'myapp.com',
userID: new TextEncoder().encode(userId),
userName: userEmail,
attestationType: 'none',
authenticatorSelection: { residentKey: 'preferred', userVerification: 'preferred' },
});
}Production Security Checklist
- Passwords hashed with argon2id or bcrypt (cost >= 12).
- JWT access token expires in <= 15 minutes; refresh token in HttpOnly cookie.
- PKCE enforced for all public OAuth clients.
- Authorization enforced on server actions and API routes (never UI only).
- Rate limiting on login and signup endpoints.
- Mandatory self-service account and personal data deletion available in user settings and public URL (
/delete-accountor/data-deletion) compliant with Apple App Store 5.1.1(v) & Google Play Data Safety policies.
Blue-Ocean Synergy & Anti-Commodity Protocol
- Mandatory Blue-Ocean Pairing: Always compose
authentication-identity-expertwithautonomous-tdd-debugger,autonomous-red-teamer,ephemeral-wasm-sandbox-executor,prompt-injection-firewall,anti-slopso commodity boilerplate is elevated into verified, self-healing production architecture. - Anti-Commodity Mandate: Elevate routine tests into continuous self-healing: validate candidate patches in
vibes sandbox --verify, fuzz OWASP/injection vectors, and gate commits viavibes skill auto-diff. - Pre-Disk Gate: Run
vibes verify-gateandvibes skill auto-diff --jsonto inject <350-token slices and eliminate placeholder slop.
Sovereign Execution, Token Efficiency & Invariants
| Dimension | Sovereign Mandate & Deterministic Contract |
| Frontier Model Cascade | High Fast / High (Gemini 4 Carbon, Gemini 4 Neon, Grok 4.7 High Fast, Claude Sonnet 5.5 High, Gemini 4 Pro) |
| Availability Fallback | Gemini 4 (Carbon/Hydrogen/Neon/Argon/Pro) -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6; Grok 4.7 -> Grok 4.6 High Fast (Zero unhandled missing-model errors) |
| KV-Cache & Token Protocol | Pin static instructions & schemas at prompt prefix (kv-cache-prefix-optimizer); pass surgical CONTEXT_MAP.md slices (<250 tokens/call) during Swarm Fan-Out |
| SaaT CLI & MCP Dispatch | CLI: vibes skill exec authentication-identity-expert <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_critic_validate, vibes_self_heal, vibes_eval_sandbox, vibes_verify_invariants |
| NFR & Anti-Slop Invariants | Zero OWASP Top 10 vectors, 0 hardcoded secrets, >= 90% branch coverage on domain logic, 0 Anti-Slop violations; 100% complete zero-placeholder output verified via node scripts/check-anti-slop.js --strict |
<a name="bahasa-indonesia"></a>
Bahasa Indonesia
Integrasi Orkestrasi
- Orkestrator Hulu: Beroperasi di bawah arahan
brainstormingdanzero-to-prod-orchestrator(Fase 2 - Fondasi, Autentikasi & Arsitektur Identitas) untuk mengimplementasikan autentikasi pengguna yang aman. - Skill Hilir & Kerja Sama:
compliance-gdpr-privacy-expert— Alur wajib penghapusan akun mandiri, crypto-shredding, dan kepatuhan hak penghapusan data UU PDP / GDPR.saas-architect— Alur kerja autentikasi B2B SaaS, perpindahan organisasi, dan onboarding.saas-multi-tenant— Matriks izin RBAC, custom claims sesi, dan akses anggota workspace.supabase-security-expert— Konfigurasi otentikasi Supabase SSR, cookie PKCE, dan kebijakan RLS.firebase-security-expert— Firebase Auth, custom token minting, dan security rules.js-backend-expert— Middleware otorisasi, verifikasi token JWT, dan session store.production-ready-hardener— Audit keamanan autentikasi pra-rilis, rate-limiting, dan header CSP.session-memory-manager— Menyimpan keputusan topologi autentikasi dan skema kredensial.
Deskripsi
Panduan tingkat produksi untuk implementasi autentikasi aman, otorisasi (RBAC/ABAC), dan manajemen identitas pengguna pada aplikasi web dan mobile modern. Mencakup integrasi Clerk, Supabase Auth, Auth.js v5 (NextAuth), Better Auth, OAuth 2.1 dengan alur PKCE, rotasi Refresh Token HttpOnly, Passkeys (WebAuthn), dan Multi-Factor Authentication (MFA) untuk stack React 19 / Next.js 16.
Rekomendasi Pemilihan Identity Provider
| Provider | Pilihan Terbaik Untuk | Keunggulan Utama | Model Harga |
| Clerk | Produk SaaS baru & B2B | DX terbaik, UI bawaan siap pakai, manajemen tim/organisasi instan | Per MAU (gratis hingga 10.000 pengguna) |
| Supabase Auth | Aplikasi dengan database Supabase | Integrasi native Row-Level Security (RLS), OAuth multi-provider | Termasuk dalam kuota Supabase |
| Auth.js v5 | Aplikasi mandiri (Self-hosted) | Kepemilikan data penuh, zero vendor lock-in, kompatibel Edge | 100% Gratis / Open-Source |
| Better Auth | Proyek TypeScript-first modern | Ekosistem plugin komprehensif, 2FA, passkeys bawaan | 100% Gratis / Open-Source |
Resep & Pedoman Teknis Implementasi
1. Standar Hashing Password (Argon2id)
import argon2 from 'argon2';
export async function hashPasswordAman(passwordPolos: string): Promise<string> {
return argon2.hash(passwordPolos, {
type: argon2.argon2id,
memoryCost: 65536, // 64 MB
timeCost: 3,
parallelism: 4,
});
}
export async function verifikasiPassword(hashTersimpan: string, passwordInput: string): Promise<boolean> {
return argon2.verify(hashTersimpan, passwordInput);
}2. Clerk Middleware pada Next.js 16 App Router
// middleware.ts
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
// Definisikan rute yang dapat diakses publik tanpa login
const rutePublik = createRouteMatcher([
'/',
'/masuk(.*)',
'/daftar(.*)',
'/api/webhooks(.*)',
]);
export default clerkMiddleware(async (auth, req) => {
if (!rutePublik(req)) {
await auth.protect();
}
});
export const config = {
matcher: [
'/((?!_next|[^?]*\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};3. Auth.js v5 (NextAuth) dengan Adapter Database Drizzle ORM
// auth.ts
import NextAuth from 'next-auth';
import GitHub from 'next-auth/providers/github';
import Google from 'next-auth/providers/google';
import { DrizzleAdapter } from '@auth/drizzle-adapter';
import { db } from '@/db';
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: DrizzleAdapter(db),
providers: [
GitHub({ clientId: process.env.AUTH_GITHUB_ID, clientSecret: process.env.AUTH_GITHUB_SECRET }),
Google({ clientId: process.env.AUTH_GOOGLE_ID, clientSecret: process.env.AUTH_GOOGLE_SECRET }),
],
session: { strategy: 'jwt' },
callbacks: {
async jwt({ token, user }) {
if (user) {
token.role = (user as any).role || 'user';
}
return token;
},
async session({ session, token }) {
if (token && session.user) {
(session.user as any).role = token.role;
}
return session;
},
},
});4. Kontrol Akses Berbasis Peran (RBAC) di Sisi Server
export type PeranPengguna = 'tamu' | 'anggota' | 'manajer' | 'administrator';
const matriksIzin: Record<PeranPengguna, string[]> = {
tamu: ['baca:artikel'],
anggota: ['baca:artikel', 'buat:komentar'],
manajer: ['baca:artikel', 'buat:komentar', 'kelola:konten'],
administrator: ['*'],
};
export function validasiIzin(peran: PeranPengguna, izinYangDibutuhkan: string): boolean {
const daftarIzin = matriksIzin[peran] || [];
return daftarIzin.includes('*') || daftarIzin.includes(izinYangDibutuhkan);
}Checklist Keamanan Otentikasi Produksi
- Password di-hash menggunakan
argon2idataubcryptdengan work factor minimal 12. - Access token berumur pendek (maksimal 15 menit) disimpan di memori runtime.
- Refresh token disimpan di cookie berflag
HttpOnly,Secure, danSameSite=Strictdengan rotasi token. - Alur OAuth 2.1 publik wajib menerapkan
PKCE(Proof Key for Code Exchange) dengan challenge SHA-256. - Otorisasi hak akses divalidasi ketat pada Server Action dan API Route (bukan sekadar menyembunyikan tombol UI).
- Proteksi brute-force dengan pembatasan laju (Rate Limiting) pada endpoint login dan pendaftaran.
- Fitur hapus akun dan data pribadi mandiri tersedia di pengaturan profil dan URL publik (
/delete-accountatau/data-deletion) memenuhi syarat Apple 5.1.1(v) dan Google Play.
Sinergi Blue-Ocean & Protokol Anti-Komoditas
- Pasangan Wajib Blue-Ocean: Selalu komposisikan
authentication-identity-expertbersamaautonomous-tdd-debugger,autonomous-red-teamer,ephemeral-wasm-sandbox-executor,prompt-injection-firewall,anti-slopagar boilerplate standar naik kelas menjadi arsitektur produksi terverifikasi dan self-healing. - Mandat Anti-Komoditas: Tingkatkan tes standar menjadi self-healing kontinu: validasi patch di
vibes sandbox --verify, fuzzing vektor OWASP/injeksi, dan gerbang commit viavibes skill auto-diff. - Gerbang Pra-Disk: Jalankan
vibes verify-gatedanvibes skill auto-diff --jsonuntuk menyuntikkan slice <350 token serta mencegah placeholder slop.
Matriks Eksekusi Berdaulat, Efisiensi Token & Invarian
| Dimensi | Mandat Berdaulat & Kontrak Deterministik |
| Kaskade Model Frontier | High Fast / High (Gemini 4 Carbon, Gemini 4 Neon, Grok 4.7 High Fast, Claude Sonnet 5.5 High, Gemini 4 Pro) |
| Invarian Fallback Ketersediaan | Gemini 4 (Carbon/Hydrogen/Neon/Argon/Pro) -> Gemini 3.8 Flash; Claude Opus 5.5 -> Claude Opus 4.6; Grok 4.7 -> Grok 4.6 High Fast (Bebas gagal saat model belum tersedia/kuota penuh) |
| Protokol Hemat Token & KV-Cache | Kunci instruksi & skema statis di prefix awal (kv-cache-prefix-optimizer); kirim potongan CONTEXT_MAP.md (<250 token/panggilan) saat Fan-Out |
| Eksekusi SaaT CLI & MCP | CLI: vibes skill exec authentication-identity-expert <audit|eval|verify|generate|blueprint> / MCP: vibes_skill_dispatch, vibes_critic_validate, vibes_self_heal, vibes_eval_sandbox, vibes_verify_invariants |
| Invarian NFR & Anti-Slop | Nol celah OWASP Top 10, 0 kredensial hardcoded, cakupan pengujian >= 90% pada logika domain, 0 pelanggaran Anti-Slop; kode 100% tuntas tanpa placeholder diverifikasi melalui node scripts/check-anti-slop.js --strict |
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.

