This repository is extracted from my Transcendence project at Hive Helsinki.
During the Transcendence project, our team built an online Ping-Pong game with a microservice architecture.
I was responsible for designing and implementing the auth/user service with Go and Gin.
I also implemented a minimal frontend prototype using Svelte for learning purposes. It's just a quick demo, so for UI/UX I just applied the default theme from shadcnui.
- Frontend: https://auth-demo-sage.vercel.app/
- Backend Swagger: https://auth-demo-x0sd.onrender.com/api/docs/index.html
screenrecord.mov
Currently supported features include:
- User registration
- Login with username or email
- Logout
- Avatar update
- OAuth login (Google)
- Two-factor authentication (TOTP)
- Friends system
- Friend listing
- Friend requests
- Online status tracking
- Redis-backed session tokens (Optional) (revocation + sliding expiration)
- Redis-backed heartbeats for online status (Optional)
gin: web frameworkgorm: ORMgo-redis: Redisgo-playground/validator v10: data validationgodotenv: environment variablesslog-gin: logginggin-swagger: Swagger (OpenAPI) docs
Svelte: frontend frameworkTailwind CSS: CSSshadcn/ui (Svelte): UI libraryZod: ValidatorSvelteKit Superforms: Form (SPA)
Please make sure you have Go installed.
git clone https://github.com/danielxfeng/auth-user-prototype.git
cd auth-user-prototypecd backend
cp .env.sample .env
make devThen navigate to http://localhost:3003/api/docs/index.html for swagger.
Required env vars for backend startup:
JWT_SECRETGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRET
The provided backend/.env.sample already includes local placeholder values for these, so backend can start even if you are not testing Google OAuth.
Redis is optional. In local development it is disabled by default (REDIS_URL= in .env).
To enable Redis locally:
# example: run redis with docker
docker run --rm -p 6379:6379 redis:latest
# enable redis mode for the backend
export REDIS_URL=redis://localhost:6379/0 # or set it in backend/.envToken extension (sliding expiration) in Redis mode:
USER_TOKEN_EXPIRYcontrols the Redis TTL and is extended on token validation.USER_TOKEN_ABSOLUTE_EXPIRYcaps the maximum lifetime via the JWTexpclaim.
cd frontend
pnpm run devThen navigate to http://localhost:5173.
Note: Google login does not work locally until Google OAuth credentials are configured.
Due to the constraints of the Hive project, SQLite was required for the project.
As a result:
- The project still uses
SQLitefor core data due to Hive constraints. - Redis-backed tokens and heartbeats are implemented, but the sliding expiration and cleanup strategy is simple.
- On the frontend side, friend auto-completion is implemented in a basic manner.