This microservice provides a comprehensive authentication solution for the Giveth ecosystem, supporting both Ethereum (SIWE) and Solana wallet-based authentication. It serves as a centralized authentication service for all Giveth Dapps.
- Multi-chain wallet authentication (Ethereum and Solana)
- Session management with JWT tokens
- Secure message signing and verification
- Integration with Safe Global for multi-sig support
- Admin dashboard for user management
- Rate limiting and security features
[Add production/staging URLs once available]
graph TD
A[Client] --> B[Auth Service]
B --> C[PostgreSQL]
B --> D[Redis]
B --> E[Ethereum Network]
B --> F[Solana Network]
B --> G[Safe Global]
H[Admin Dashboard] --> B
- Node.js
- Express.js
- TypeScript
- PostgreSQL (primary database)
- Redis (session storage and rate limiting)
- TypeORM (database ORM)
- AdminJS (admin dashboard)
- SIWE (Sign-In with Ethereum)
- Safe Global Protocol Kit
- Solana Web3.js
- User initiates sign-in with their wallet (Ethereum or Solana)
- Service generates authentication message
- User signs message with their wallet
- Service verifies signature and creates session
- JWT token issued for subsequent requests
- Session data stored in Redis
- User data persisted in PostgreSQL
- Node.js (v16 or higher)
- PostgreSQL (v12 or higher)
- Redis (v6 or higher)
- Git
- Docker and Docker Compose (optional)
- Clone the repository:
git clone [repository-url]
- Install dependencies:
npm install
- Create
.env
file with required environment variables:
PORT=3000
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=siwe_auth
REDIS_HOST=localhost
REDIS_PORT=6379
JWT_SECRET=your_jwt_secret
ADMIN_EMAIL=[email protected]
ADMIN_PASSWORD=your_admin_password
-
Using Docker Compose (Recommended)
docker-compose -f docker-compose-local-postgres-redis.yml up -d
-
Manual Setup
- Install PostgreSQL and Redis
- Create database and user
- Configure connection settings
We use TypeORM for database migrations.
-
Create a new migration
npm run migration:create <migration-name>
-
Run migrations
# Development npm run db:migrate:run:local # Staging npm run db:migrate:run:staging # Production npm run db:migrate:run:production
-
Revert migrations
npm run db:migrate:revert:local
Development mode:
npm start
Production mode:
npm run build
npm run start:server:production
Run tests:
# All tests
npm test
# Specific test files
npm run test:applicationRepository
npm run test:organizationRepository
npm run test:tokenRouter
npm run test:donationRouter
The API documentation is available at /api-docs
when the server is running. It's automatically generated using TSOA.
- Development: Local development environment
- Staging: [Add staging environment details]
- Production: [Add production environment details]
-
Build the application:
npm run build
-
Run database migrations:
npm run db:migrate:run:production
-
Start the server:
npm run start:server:production
[Add details about CI/CD pipeline once implemented]
-
Database Connection Issues
- Verify PostgreSQL connection settings
- Check network connectivity
- Ensure correct environment variables are set
-
Redis Connection Issues
- Verify Redis connection settings
- Check Redis server status
- Ensure correct environment variables are set
-
Authentication Failures
- Verify wallet connection
- Check message signing process
- Validate nonce generation and verification
- Application logs are written to
logs/
directory - Use environment variable
DEBUG=true
for verbose logging - Monitor PostgreSQL and Redis logs for database-related issues
[Add contribution guidelines]
ISC