A fast and lightweight user authentication platform built with Go Fiber, supporting:
- π User Signup & Login
- β OTP-based User Verification via SMS
- π§βπΌ Role management for Buyer/Seller
- π User Signup with email, password, and phone number
- π Secure Login with hashed passwords (bcrypt)
- π² OTP Verification (via SMS API like Twilio)
- π₯ Role Assignment: Users can become Buyers or Sellers
- π§Ύ Basic JWT-based session/token support
- π§ͺ Structured modular code for extensibility
- Go (Golang) β Language
- Fiber β Fast HTTP web framework
- GORM β ORM for PostgreSQL/MySQL (optional)
- JWT β JSON Web Tokens for auth
- Bcrypt β Password hashing
- SMS Gateway API β For OTP delivery (e.g., Twilio, Fast2SMS)
go-fiber-user-auth-microservice/
βββ main.go
βββ model/
β βββ user.go
βββ handler/
β βββ auth.go
βββ routes/
β βββ routes.go
βββ utils/
β βββ jwt.go
β βββ otp.go
βββ config/
β βββ db.go
βββ go.mod```
---
## π Getting Started
### 1. Clone the Repo
```bash
git clone https://github.com/manupanand-freelence-developer/go-fiber-user-auth-microservice.git
cd go-fiber-user-auth-microservice
2. Initialize Go Modules
go mod tidy
3. Run the App
go run main.go
π οΈ Environment Variables (or .env)
PORT=3000
JWT_SECRET=supersecretkey
DB_URL=postgres://user:pass@localhost:5432/mydb
SMS_API_KEY=your_sms_api_key
Use godotenv if needed for .env loading.
π API Endpoints (Planned)
Method Endpoint Description
POST /signup Register new user
POST /login Login user and get token
POST /verify Verify OTP sent via SMS
POST /role/buyer Set user as buyer
POST /role/seller Set user as seller
π§ͺ Future Enhancements
Email + SMS fallback OTP support
Admin role and dashboard
Password reset via OTP
Rate limiting and brute-force protection
MIT License Β© 2025 [Manu P Anand]
π¬ Contact
[www.linkedin.co.in.manupanand]