Authentication System
Enterprise-grade authentication powered by Better Auth with OAuth, JWT, sessions, RBAC, and native MoroJS integration.
Authentication
Enterprise-grade authentication powered by Better Auth. OAuth, SSO, RBAC, and more. Secure by default, flexible when needed.
On this page
Authentication That Just Works
Add OAuth, SSO, and RBAC with a few lines of code.
Powered by Better Auth, secure by default.
It's This Simple
Add OAuth authentication
typescript
Why Authentication Matters
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.
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
It's This Easy
Protect routes with role-based access control. That's it.
Protect routes with RBAC
typescript
Why It Makes Sense
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.
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