Authentication System
Enterprise-grade authentication powered by Better Auth with OAuth, JWT, sessions, RBAC, and native MoroJS integration.
Core Systems
Authentication
Enterprise-grade authentication powered by Better Auth. OAuth, SSO, RBAC, and more. Secure by default, flexible when needed.
Overview
Without proper authentication, your API is vulnerable. With MoroJS, you get enterprise-grade security out of the box.
Traditional auth setup requires multiple libraries, complex configuration, and manual security handling. We handle that automatically.
Add OAuth authentication
typescript
Without Proper Auth
- Manual session management
- Complex OAuth integration
- Security vulnerabilities
- No built-in RBAC
With MoroJS
- One-line OAuth setup
- Built-in RBAC system
- Secure by default
- Enterprise SSO support
OAuth Ready
GitHub, Google, Discord, Microsoft, LinkedIn, and more. One-line setup.
Enterprise SSO
Okta, Auth0, AWS Cognito integration. Enterprise-ready out of the box.
RBAC Built-in
Role-based access control with permissions. Protect routes easily.
Protect routes with RBAC
typescript
How It Works
MoroJS authentication is powered by Better Auth, providing secure OAuth flows, session management, and role-based access control. The authentication middleware automatically handles OAuth callbacks, session creation, and route protection.
Quick Setup
Set up authentication in three steps:
1. Environment Variables
bash
2. Add Authentication Middleware
typescript
3. Protect Routes
typescript
Role-Based Access Control
Protect routes with role-based access control. Use built-in helpers or create custom authorization logic.
RBAC Examples
typescript
Available Helpers
requireAuth()- Require user to be authenticatedrequireRole(['admin'])- Require specific rolerequireAdmin()- Require admin role (shorthand)requireAuth({ authorize })- Custom authorization logic