Session Authentication
Session authentication is designed for browser-based applications where users log in through the FLTR web interface. It uses HTTP-only cookies for secure, stateless authentication.Overview
Session authentication provides:- 15,000 requests/hour rate limit
- HTTP-only cookies to prevent XSS attacks
- CSRF protection built-in
- Automatic session management by the browser
- Same security as OAuth without the complexity
When to Use Sessions
Best for:- Single-page applications (SPAs)
- Server-rendered web apps
- Admin dashboards
- Internal tools
- Mobile apps (use OAuth)
- Server-to-server integrations (use API keys)
- Third-party integrations (use OAuth)
Quick Start
1
Enable Session Auth
Configure your application to use credentials:
2
Redirect to Login
Send users to the FLTR login page:
3
Make API Calls
After login, session cookies are automatically included:
Implementation
Frontend (React Example)
Backend (Express.js Example)
If you need server-side session management:CORS Configuration
For browser-based requests, configure CORS properly:Development
Production
Add your domain to FLTR’s allowed origins:- Go to Settings → CORS
- Add your production domain:
https://yourdomain.com - Save changes
CSRF Protection
Session authentication includes built-in CSRF protection using the double-submit cookie pattern.How It Works
- FLTR sets a CSRF token in a cookie
- Your app reads the cookie and sends it in a header
- FLTR validates the header matches the cookie
Implementation
Axios Configuration
Axios automatically handles CSRF tokens:Session Management
Check Session Status
Extend Session
Sessions automatically extend on each request. To manually extend:Logout
Security Best Practices
Cookie Security
FLTR sets secure cookie attributes:Frontend Security
Do:- ✅ Use
credentials: 'include'for all API requests - ✅ Implement CSRF protection
- ✅ Use HTTPS in production
- ✅ Validate session before sensitive operations
- ✅ Implement logout on idle timeout
- ❌ Store session data in localStorage
- ❌ Access cookies from JavaScript
- ❌ Make API calls without CSRF tokens
- ❌ Trust client-side session checks alone
Backend Security
Do:- ✅ Use httpOnly cookies
- ✅ Set SameSite=Lax or Strict
- ✅ Implement session expiry
- ✅ Validate CSRF tokens
- ✅ Use secure session stores (Redis)
- ❌ Store sessions in memory (doesn’t scale)
- ❌ Use predictable session IDs
- ❌ Send session cookies over HTTP
- ❌ Trust client-provided session data
Error Handling
401 Unauthorized
Session expired or invalid:403 Forbidden
CSRF token invalid:Rate Limiting
Session authentication provides 15,000 requests/hour - the same as OAuth. Check rate limit status:Complete Examples
Next.js App Router
Vue.js 3
Troubleshooting
Cookies Not Being Set
Cause: CORS configuration issue Solution:- Ensure
credentials: 'include'is set - Add your domain to allowed origins in FLTR settings
- Use HTTPS in production (required for secure cookies)