- Renamed auth-service to iam-service across various files for consistency. - Updated deployment workflows, database migration scripts, and documentation to reflect the service name change. - Enhanced bilingual documentation for clarity on the new service structure and usage. - Removed outdated references to auth-service in scripts and configuration files to streamline the project structure.
150 lines
3.3 KiB
Markdown
150 lines
3.3 KiB
Markdown
# Quick Start Guide
|
|
|
|
## 🚀 Getting Started
|
|
|
|
### 1. Install Dependencies
|
|
```bash
|
|
pnpm install
|
|
```
|
|
|
|
### 2. Setup Environment
|
|
```bash
|
|
cp env.local.example .env.local
|
|
# Edit .env.local with your configuration
|
|
```
|
|
|
|
### 3. Setup Database
|
|
```bash
|
|
# Generate Prisma Client
|
|
pnpm prisma:generate
|
|
|
|
# Run migrations
|
|
pnpm prisma:migrate
|
|
|
|
# Seed database (creates admin user)
|
|
pnpm prisma:seed
|
|
```
|
|
|
|
### 4. Start Development Server
|
|
```bash
|
|
pnpm dev
|
|
```
|
|
|
|
Service will start on `http://localhost:4000`
|
|
|
|
## 📝 Default Credentials
|
|
|
|
After seeding:
|
|
- **Admin**: `admin@goodgo.com` / `admin123`
|
|
- **Test User**: `test@goodgo.com` / `test123`
|
|
|
|
## 🔑 API Testing
|
|
|
|
### Register User
|
|
```bash
|
|
curl -X POST http://localhost:4000/api/v1/auth/register \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"email": "user@example.com",
|
|
"password": "password123",
|
|
"username": "testuser"
|
|
}'
|
|
```
|
|
|
|
### Login
|
|
```bash
|
|
curl -X POST http://localhost:4000/api/v1/auth/login \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"email": "admin@goodgo.com",
|
|
"password": "admin123"
|
|
}'
|
|
```
|
|
|
|
### Get Current User
|
|
```bash
|
|
curl -X GET http://localhost:4000/api/v1/auth/me \
|
|
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
|
|
```
|
|
|
|
### Check Permissions
|
|
```bash
|
|
curl -X GET "http://localhost:4000/api/v1/rbac/permissions/check?resource=users&action=read&scope=all" \
|
|
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
|
|
```
|
|
|
|
## 🔐 Social Login Setup
|
|
|
|
### Google OAuth
|
|
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
2. Create OAuth 2.0 credentials
|
|
3. Add to `.env.local`:
|
|
```
|
|
GOOGLE_CLIENT_ID=your-client-id
|
|
GOOGLE_CLIENT_SECRET=your-client-secret
|
|
GOOGLE_REDIRECT_URI=http://localhost:4000/api/v1/auth/google/callback
|
|
```
|
|
|
|
### Facebook OAuth
|
|
1. Go to [Facebook Developers](https://developers.facebook.com/)
|
|
2. Create App and get credentials
|
|
3. Add to `.env.local`:
|
|
```
|
|
FACEBOOK_APP_ID=your-app-id
|
|
FACEBOOK_APP_SECRET=your-app-secret
|
|
FACEBOOK_REDIRECT_URI=http://localhost:4000/api/v1/auth/facebook/callback
|
|
```
|
|
|
|
### GitHub OAuth
|
|
1. Go to GitHub Settings > Developer settings > OAuth Apps
|
|
2. Create new OAuth App
|
|
3. Add to `.env.local`:
|
|
```
|
|
GITHUB_CLIENT_ID=your-client-id
|
|
GITHUB_CLIENT_SECRET=your-client-secret
|
|
GITHUB_REDIRECT_URI=http://localhost:4000/api/v1/auth/github/callback
|
|
```
|
|
|
|
## 🔒 MFA Setup
|
|
|
|
### Enable TOTP
|
|
1. Call `POST /api/v1/mfa/totp/enable` to get QR code
|
|
2. Scan QR code with authenticator app (Google Authenticator, Authy, etc.)
|
|
3. Call `POST /api/v1/mfa/totp/verify` with token from app
|
|
|
|
## 📊 Health Checks
|
|
|
|
- `GET /health` - Basic health check
|
|
- `GET /health/ready` - Readiness probe (checks database)
|
|
- `GET /health/live` - Liveness probe
|
|
|
|
## 🐳 Docker Deployment
|
|
|
|
```bash
|
|
cd ../../deployments/local
|
|
docker-compose up -d iam-service
|
|
```
|
|
|
|
## 📚 Documentation
|
|
|
|
- See `README.md` for full documentation
|
|
- See `IMPLEMENTATION.md` for implementation details
|
|
- API docs available at `/api-docs` when running
|
|
|
|
## 🛠️ Troubleshooting
|
|
|
|
### Database Connection Issues
|
|
- Check `DATABASE_URL` in `.env.local`
|
|
- Ensure database is running
|
|
- Run `pnpm prisma:generate` if schema changed
|
|
|
|
### Redis Connection Issues
|
|
- Check `REDIS_URL` in `.env.local`
|
|
- Ensure Redis is running
|
|
- Default: `redis://localhost:6379`
|
|
|
|
### JWT Errors
|
|
- Ensure `JWT_SECRET` is set in `.env.local`
|
|
- Use strong, random secrets in production
|
|
- Never commit secrets to git
|