Authentication security
JWT tokens
The Cloud API issues JSON Web Tokens for authentication: Access tokens:- Expire after 30 minutes
- Stored in httpOnly cookies (
devkit4ai-token) - Not accessible to JavaScript
- Automatically included in API requests
- Expire after 7 days
- Stored in httpOnly cookies (
devkit4ai-refresh-token) - Used to obtain new access tokens
- Revoked on logout
Cookie configuration
lib/auth-server.ts
API key security
Storage and handling
Environment variables:- Store keys in
.env.localfor development - Use hosting provider secrets for production
- Never commit keys to version control
Key rotation
1
Generate new keys
In Cloud Admin, create new developer and project API keys.
2
Update environment variables
Set new keys in your hosting provider and local
.env.local.3
Deploy and verify
Deploy with new keys and confirm application works.
4
Revoke old keys
In Cloud Admin, revoke the old keys after confirming new ones work.
Password security
The Cloud API enforces strong password requirements: Minimum requirements:- At least 8 characters
- One uppercase letter
- One lowercase letter
- One digit
components/register-form.tsx
HTTPS enforcement
Production configuration
All production deployments must use HTTPS: Vercel, Netlify: Automatic HTTPS with free SSL certificates Custom domains:- Configure SSL certificate
- Redirect HTTP to HTTPS
- Enable HSTS headers
middleware.ts
CORS configuration
The Cloud API restricts cross-origin requests: Allowed origins:- Your registered domain(s)
localhost:*for development
- Navigate to Project Settings
- Add allowed origins
- Wildcards supported for subdomains
Input validation
Always validate user input: Email addresses:lib/return-url.ts
Rate limiting
The Cloud API implements rate limits: Per project:- Authentication: 10 requests/minute
- Data endpoints: 100 requests/minute
- AI generation: 10 requests/minute
Security headers
Configure security headers innext.config.ts:
next.config.ts
Dependency security
Keep dependencies updated:- Go to GitHub repository settings
- Enable Dependabot alerts
- Configure automatic PR creation
Monitoring and logging
Never log sensitive data:- Failed login attempts
- API key usage
- Permission denials
- Rate limit hits
Security checklist
Environment security
Environment security
- All secrets in environment variables, not code
-
.env.localin.gitignore - Different keys for dev/staging/production
- HTTPS enforced in production
Authentication security
Authentication security
- JWT tokens in httpOnly cookies
- Password validation client and server-side
- Logout clears all tokens
- Protected routes check authentication
API security
API security
- API keys stored server-side only
- Rate limiting implemented
- Input validation on all forms
- Error messages don’t leak sensitive info
Code security
Code security
- Dependencies regularly updated
- No sensitive data in logs
- Security headers configured
- CORS properly configured

