A high-performance authentication and authorization service built with Go, designed as part of a microservices video processing cluster. This service handles user authentication, JWT token management, and acts as a proxy for video analysis and transcoding operations.
This service acts as an authentication gateway for a video processing cluster, providing:
GET /health - Service health checkGET /metrics - Prometheus metricsPOST /auth/register - User registrationPOST /auth/login - User loginGET /auth/profile - Get user profilePUT /auth/profile - Update user profilePOST /auth/video/analyze - Submit video for analysisGET /auth/video/analyze - List user's video analysesGET /auth/video/analyze/{id} - Get specific analysis detailsPOST /auth/video/transcode - Submit video for transcodingGET /auth/video/transcode - List user's transcoding jobsGET /auth/video/transcode/{id} - Get specific transcoding job detailsGET /auth/video/transcode/{id}/download - Download processed video from S3# Pull the latest image
docker pull moootid/auth-service:latest
# Run with environment variables
docker run -p 8080:8080 \
-e DB_HOST=your-db-host \
-e DB_PORT=26257 \
-e DB_USER=your-db-user \
-e DB_PASSWORD=your-db-password \
-e DB_NAME=microservices \
-e JWT_SECRET=your-secret-key \
moootid/auth-service:latest
git clone https://github.com/moootid/auth-service.git
cd auth-service
.env file with your configuration:DB_HOST=localhost
DB_PORT=26257
DB_USER=root
DB_PASSWORD=your-password
DB_NAME=microservices
DB_SSLMODE=disable
JWT_SECRET=your-secret-key-here
docker-compose up -d
git clone https://github.com/moootid/auth-service.git
cd auth-service
go mod download
export DB_HOST=localhost
export DB_PORT=26257
export DB_USER=root
export DB_PASSWORD=your-password
export DB_NAME=microservices
export JWT_SECRET=your-secret-key
go run main.go
The service will start on port 8080 by default.
| Variable | Description | Default |
|---|---|---|
PORT | Service port | 8080 |
DB_HOST | Database host | localhost |
DB_PORT | Database port | 26257 |
DB_USER | Database user | root |
DB_PASSWORD | Database password | "" |
DB_NAME | Database name | microservices |
DB_SSLMODE | Database SSL mode | disable |
JWT_SECRET | JWT signing secret | your-secret-key |
The service uses GORM for database operations and supports PostgreSQL/CockroachDB. Ensure your database is running and accessible with the provided credentials.
Required tables will be automatically created by GORM migrations:
users - User profiles and authentication datavideo_analyses - Video analysis job trackingtranscoding_jobs - Video transcoding job trackingcurl -X POST http://localhost:8080/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "securepassword"
}'
curl -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "securepassword"
}'
# Use the JWT token from login response
curl -X GET http://localhost:8080/auth/profile \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
curl -X POST http://localhost:8080/auth/video/analyze \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"video_url": "https://example.com/video.mp4",
"analysis_type": "content_detection"
}'
GET /health - Returns service statusGET /metrics - Prometheus metrics endpointauth-service/
āāā main.go # Application entry point
āāā database/
ā āāā db.go # Database connection and configuration
āāā handlers/
ā āāā auth.go # Authentication handlers
ā āāā analyze.go # Video analysis proxy handlers
ā āāā transcode.go # Video transcoding proxy handlers
āāā middleware/
ā āāā auth.go # JWT authentication middleware
ā āāā metrics.go # Prometheus metrics middleware
āāā models/
ā āāā user.go # User data models
ā āāā video_analyses.go # Video analysis models
ā āāā transcoding_job.go # Transcoding job models
āāā Dockerfile # Container configuration
āāā docker-compose.yml # Multi-container setup
āāā go.mod # Go module dependencies
āāā go.sum # Dependency checksums
This project is licensed under the MIT License - see the LICENSEā file for details.
This auth service is part of a larger video processing cluster:
Docker Hub: moootid/auth-service:latestā
GitHub: moootid/auth-serviceā
Content type
Image
Digest
sha256:62f5712d8ā¦
Size
15.2 MB
Last updated
about 1 year ago
docker pull moootid/auth-service