rugi-auth
v2.5.0
Published
Centralized authentication service with multi-app role management
Maintainers
Readme
Rugi Auth
A secure, centralized authentication service with multi-app role management. Built with Express, TypeScript, and Prisma.
🚀 Quick Start
Prerequisites:
1. Create New Project
Use the CLI to scaffold a new authentication server. This sets up the project structure, keys, and configuration for you.
npx rugi-auth init <your-project-name>Follow the interactive prompts to configure your project.
2. Start Services
Navigate to your new project directory and start the infrastructure (PostgreSQL & Redis).
cd <your-project-name>
docker-compose up -dNote: Redis is auto-configured on port 6380 to avoid conflicts.
3. Initialize
Run the setup script to migrate the database, generate keys, and create your superadmin account.
# Run database migrations
npm run prisma:migrate
# Complete setup (Keys, Default App, Superadmin)
npm run setup4. Run Server
npm run devThe API will be available at http://localhost:7100.
🔑 Key Features
- Centralized Auth: Single user identity across multiple applications.
- Security First:
- RSA Keys: RS256 JWT signing.
- Argon2id: Memory-hard password hashing.
- Rate Limiting: Redis-backed distributed rate limiting.
- Protection: Patched against timing attacks and IP spoofing.
- Role Management: Granular, app-specific roles.
- OTP Support: Secure email-based one-time passwords.
- Audit Logs: detailed tracking of all security events.
🔌 API Reference
Full documentation is available at /docs (Swagger UI) when the server is running.
| Method | Endpoint | Description |
| :--- | :--- | :--- |
| POST | /register | Register a new user |
| POST | /login | Login with email/password |
| POST | /refresh | Refresh access token |
| POST | /revoke | Revoke refresh token |
| GET | /me | Get current user profile |
| GET | /.well-known/jwks.json | Public keys (JWKS) |
🛠 Project Structure
src/- Source codeprisma/- Database schemakeys/- Generated RSA keys (Do not commit!)docker/- Docker configuration
⚙️ Configuration
Copy .env.example to .env to customize settings.
Key Variables:
DATABASE_URL: Postgres connection string.REDIS_HOST/REDIS_PORT: Redis connection (defaults to Docker values).JWT_ACCESS_TOKEN_EXPIRY: Duration of access tokens (default: 10m).
🛡️ deployment
For production:
- Keys: Ensure
keys/directory is secure and persistent. - Redis: Configure a persistent Redis instance for rate limiting in
.env. - Process Manager: Use PM2 (
npm run start:pm2) or Docker.
