supabase
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
Manages authentication flow for MutuaPIX (Laravel Sanctum + Next.js), handles mock mode security, and validates environment configurations
Full skill instructions
This skill manages the complete authentication system for MutuaPIX, covering:
Authentication Flow:
1. GET /sanctum/csrf-cookie → Receives XSRF-TOKEN cookie
2. POST /api/v1/login {email, password, X-XSRF-TOKEN header}
3. Backend validates credentials
4. Returns {token, user} (token expires in 24h)
5. All requests include: Authorization: Bearer {token}
Configuration:
matrix.mutuapix.comwebFiles:
backend/routes/api/auth.php - Authentication routesbackend/app/Http/Controllers/Auth/AuthController.php - Login/logout logicbackend/config/sanctum.php - Sanctum configurationbackend/config/cors.php - CORS settingsState Management:
frontend/src/stores/authStore.tsAuthorization: Bearer {token}Files:
frontend/src/stores/authStore.ts - Authentication statefrontend/src/services/auth.service.ts - API callsfrontend/src/hooks/useAuth.ts - Authentication hookfrontend/src/providers/AuthProvider.tsx - Auth context providerPurpose: Allow frontend development without running backend API Problem: Implementation has security vulnerabilities if not properly configured
src/lib/env.ts)// ✅ CORRECT: Uses NEXT_PUBLIC_NODE_ENV for client-side detection
export const IS_PRODUCTION = process.env.NEXT_PUBLIC_NODE_ENV === 'production';
export const IS_DEVELOPMENT = !IS_PRODUCTION;
⚠️ WHY THIS IS CRITICAL:
process.env.NODE_ENV is undefined in Next.js client-side codeNEXT_PUBLIC_* variables are replaced at build timeprocess.env.NODE_ENV always evaluated to false (insecure!)File: frontend/src/stores/authStore.ts:91-96
❌ INSECURE (Current State):
user: devLocalUser, // Mock admin user by default
token: devLocalToken, // "local-dev-token"
isAuthenticated: true, // Already authenticated!
✅ SECURE (Required Fix):
user: null, // Unauthenticated by default
token: null,
isAuthenticated: false,
File: frontend/src/components/auth/MockLoginButton.tsx
Status: ✅ Secured (renders null in production)
if (IS_PRODUCTION) {
return null; // Button not rendered in production
}
File: /var/www/mutuapix-frontend-production/.env.production
# ✅ CORRECT CONFIGURATION
NEXT_PUBLIC_NODE_ENV=production
NEXT_PUBLIC_API_URL=https://api.mutuapix.com
NEXT_PUBLIC_API_BASE_URL=https://api.mutuapix.com
NEXT_PUBLIC_USE_AUTH_MOCK=false
NEXT_PUBLIC_AUTH_DISABLED=false
NEXT_PUBLIC_DEBUG=false
Critical: Must run npm run build (NOT just PM2 restart) for changes to take effect!
File: frontend/.env.local
# ✅ RECOMMENDED CONFIGURATION
NEXT_PUBLIC_NODE_ENV=development
NEXT_PUBLIC_API_URL=http://localhost:8000 # Local backend!
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
NEXT_PUBLIC_USE_AUTH_MOCK=true # Enable mock for dev
NEXT_PUBLIC_AUTH_DISABLED=false
NEXT_PUBLIC_DEBUG=true
⚠️ NEVER point local environment to production API!
When deploying authentication changes:
curl https://api.mutuapix.com/sanctum/csrf-cookie -Issh [email protected] 'pm2 restart mutuapix-api'.env.production exists on VPS with correct valuesNEXT_PUBLIC_NODE_ENV=production is setNEXT_PUBLIC_USE_AUTH_MOCK=false is set.next cache: rm -rf .nextnpm run buildpm2 restart mutuapix-frontendIS_PRODUCTION: true// 1. Navigate to production login
await mcp__chrome-devtools__navigate_page({
url: 'https://matrix.mutuapix.com/login'
});
// 2. Check console for mock mode messages
const console = await mcp__chrome-devtools__list_console_messages();
// Should NOT contain: "🔓 Acesso liberado no modo desenvolvimento"
// 3. Take snapshot to verify mock button not rendered
const snapshot = await mcp__chrome-devtools__take_snapshot();
// Should NOT contain: "Login de Desenvolvimento" button
// 4. Monitor network requests after login
const requests = await mcp__chrome-devtools__list_network_requests({
resourceTypes: ['xhr', 'fetch']
});
// Should call: https://api.mutuapix.com/api/v1/login
// Should NOT call: back-api-mutuapix.test (old dev URL)
Symptoms:
Diagnosis:
# Check production environment file
ssh [email protected] 'cat /var/www/mutuapix-frontend-production/.env.production | grep NODE_ENV'
Solution:
NEXT_PUBLIC_NODE_ENV=production in .env.productionssh [email protected] 'cd /var/www/mutuapix-frontend-production && rm -rf .next'ssh [email protected] 'cd /var/www/mutuapix-frontend-production && npm run build'ssh [email protected] 'pm2 restart mutuapix-frontend'Symptoms:
back-api-mutuapix.testDiagnosis:
# Check if environment variables were embedded in build
ssh [email protected] 'grep -r "back-api-mutuapix.test" /var/www/mutuapix-frontend-production/.next/static/chunks/ | head -5'
Solution:
.env.productiongrep -r "api.mutuapix.com" .next/static/chunks/ | head -1Symptoms:
Diagnosis:
# Test CSRF token endpoint
curl -I https://api.mutuapix.com/sanctum/csrf-cookie
# Check CORS headers
curl -I https://api.mutuapix.com/api/v1/login \
-H "Origin: https://matrix.mutuapix.com"
Solution:
backend/config/sanctum.php has matrix.mutuapix.com in stateful domainsbackend/config/cors.php allows frontend origin.mutuapix.com)Symptoms:
Diagnosis:
// Check authStore default state
// File: frontend/src/stores/authStore.ts:91-96
Solution:
user: null,
token: null,
isAuthenticated: false,
Clear State:
// In browser console
localStorage.clear();
sessionStorage.clear();
location.reload();
Verify Unauthenticated:
/login/user/dashboard or other protected routesTest Login:
localStorage['auth-storage']Test Protected Routes:
/user/dashboardAuthorization: Bearer {token} in headersTest Logout:
/loginlocalStorage['auth-storage'] should be emptyUse MCP Chrome DevTools for automated verification (see "Post-Deployment Verification" section above).
.env files (except .env.example)1.1.0 (2025-10-16): Added comprehensive security audit
1.0.0 (2025-10-10): Initial authentication skill
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.
A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.
Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.
Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".
Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.
Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.
Send, read, and manage Gmail messages, drafts, labels, and account settings.
Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.
Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.
Discover your celebrity doppelgänger with StarByFace!
GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams
Detect AI-generated voices to protect against audio fraud.
Ensure Your Content's Originality with AI Plagiarism Checker
Upscale images by 400% without quality loss
Protect your social media from copyright disputes
Accurately Detect AI-Generated Content with TheChecker.AI
Chrome extension that detects and flags AI-generated content