Enterprise Authentication Platform
Comprehensive, secure, and developer-friendly authentication for modern applications
Enterprise-grade Authentication
Modern Auth provides a battle-tested authentication infrastructure built on industry standards and designed for enterprise applications with stringent security requirements.
- Advanced JWT implementation with automatic key rotation
- Argon2id password hashing with adaptive work factors
- Sophisticated CSRF protection with dual-token pattern
- Intelligent rate limiting with IP reputation analysis
- Secure HTTP-only cookies with SameSite and domain controls
- Session management with device fingerprinting
- OAuth 2.0 and OpenID Connect provider integrations
- SSO capabilities with SAML 2.0 support
import { jwtService } from '@modern-auth/core';
const token = await jwtService.createToken({
subject: user.id,
audience: 'api:access',
claims: {
roles: user.roles,
permissions: user.permissions,
deviceId: fingerprint.id
},
expiresIn: '4h'
});
try {
const result = await jwtService.validateToken(token, {
audience: 'api:access',
validateFingerprint: true,
requirePermissions: ['users:read']
});
return result.subject;
} catch (error) {
logger.security.warn('Invalid token', { error, token: tokenMask(token) });
throw new AuthError('INVALID_TOKEN');
}
Enterprise Identity Management
Modern Auth delivers comprehensive identity and access management for organizations of any size. Our system handles millions of users with enterprise-ready performance and compliance.
- Advanced user registration with identity verification
- Role-based access control with fine-grained permissions
- Multi-factor authentication with multiple methods
- Enterprise SSO integration capabilities
- Automated compliance workflows (GDPR, CCPA, HIPAA)
- Customizable security policies
- User directory integrations (LDAP, Active Directory)
- User impersonation with full audit trails
const userSchema = new Schema({
profile: {
firstName: { type: String, required: true },
lastName: { type: String, required: true },
displayName: String,
avatarUrl: String,
locale: { type: String, default: 'en-US' }
},
email: {
address: { type: String, required: true, unique: true },
verified: { type: Boolean, default: false },
verificationToken: { type: String, select: false }
},
security: {
password: { type: String, required: true, select: false },
mfaEnabled: { type: Boolean, default: false },
mfaMethods: [String],
passwordHistory: [{ type: String, select: false }],
lastPasswordChange: Date
},
roles: [{ type: String, ref: 'Role' }],
permissions: [String],
status: { type: String, enum: ['active', 'suspended', 'locked'], default: 'active' },
metadata: { type: Map, of: Schema.Types.Mixed }
}, { timestamps: true });
Advanced Theming System
Modern Auth includes a sophisticated theming engine that ensures consistent brand experiences while respecting user preferences and accessibility needs.
- CSS variable-based theme architecture for maximum flexibility
- Hydration-safe implementation to eliminate FOUC (flash of unstyled content)
- Automatic system preference detection with media query subscriptions
- Persistent theme settings with local storage and server-side preference sync
- Smooth theme transitions with configurable animation durations
- WCAG 2.1 AA/AAA compliant color contrast in all themes
- Support for multiple theme variants beyond just light/dark
- Theme tokens API for consistent component styling
import { createThemeContext } from '@modern-auth/theme';
const themeConfig = {
variants: ['light', 'dark', 'highContrast'],
defaultVariant: 'system',
transitionDuration: 200,
tokens: {
light: {
colors: {
primary: '#0070f3',
background: '#ffffff',
text: '#111827',
/* Additional token definitions */
}
},
dark: {
colors: {
primary: '#3b82f6',
background: '#0f172a',
text: '#f3f4f6',
/* Additional token definitions */
}
},
}
};
export const { ThemeProvider, useTheme } = createThemeContext(themeConfig);
Elegant Error Handling System
Modern Auth provides a comprehensive error handling system that delivers consistent, user-friendly error responses across your entire application.
- Centralized error management with consistent formatting
- Beautiful, theme-aware error pages for common HTTP status codes
- Detailed developer error information in development mode
- Structured error logging with context preservation
- Automatic retry mechanisms for transient failures
- Rate limiting with user-friendly messaging
- Internationalized error messages
- Security-conscious error reporting (no stack traces in production)
import { createErrorHandler } from '@modern-auth/errors';
const errorConfig = {
types: {
AUTH: {
INVALID_CREDENTIALS: {
code: 'AUTH_001',
status: 401,
message: 'Invalid username or password'
},
ACCOUNT_LOCKED: {
code: 'AUTH_002',
status: 403,
message: 'Account locked',
retryAfter: 30
},
},
VALIDATION: {
REQUIRED_FIELD: {
code: 'VAL_001',
status: 400,
message: 'Required field missing'
},
}
},
defaultError: {
code: 'ERR_999',
status: 500,
message: 'An unexpected error occurred'
}
};
export const { AppError, handleError } = createErrorHandler(errorConfig);