Secure user management backend for Go applications.
Official client libraries: Gouserfy SDKs
chmod +x setup.sh
./setup.shcp .env.example .env
# Edit .env with your settings
# Start PostgreSQL
docker run -d --name gouserfy-postgres \
-e POSTGRES_USER=gouserfy \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=gouserfy \
-p 5432:5432 postgres:18-alpine
# Run migrations
go install github.com/pressly/goose/v3/cmd/goose@latest
goose -dir migrations postgres "postgres://gouserfy:secret@localhost:5432/gouserfy?sslmode=disable" up
# Start server
go run cmd/gouserfy/main.godocker-compose up -d| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/register |
Register new user |
| POST | /api/v1/auth/login |
Login |
| POST | /api/v1/auth/login/2fa |
Complete 2FA login |
| POST | /api/v1/auth/refresh |
Refresh tokens |
| POST | /api/v1/auth/logout |
Logout |
| POST | /api/v1/auth/logout/all |
Logout all sessions |
| POST | /api/v1/auth/verify-email |
Verify email |
| POST | /api/v1/auth/forgot-password |
Request password reset |
| POST | /api/v1/auth/reset-password |
Reset password |
| POST | /api/v1/auth/change-password |
Change password |
| POST | /api/v1/auth/2fa/enable |
Enable 2FA |
| POST | /api/v1/auth/2fa/confirm |
Confirm 2FA setup |
| POST | /api/v1/auth/2fa/disable |
Disable 2FA |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/users/me |
Get current user |
| GET | /api/v1/users/{id} |
Get user by ID |
| DELETE | /api/v1/users/me |
Delete account |
| GET | /api/v1/users/me/profile |
Get profile |
| PUT | /api/v1/users/me/profile |
Update profile |
| GET | /api/v1/users/me/preferences |
Get preferences |
| PUT | /api/v1/users/me/preferences |
Update preferences |
| GET | /api/v1/users/me/roles |
Get roles |
| PUT | /api/v1/users/me/username |
Update username |
curl -X POST http://localhost:8080/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "SecurePass123!"}'curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "SecurePass123!"}'Response:
{
"tokens": {
"access_token": "eyJhbG...",
"refresh_token": "abc123...",
"expires_at": "2026-02-05T12:30:00Z"
},
"user": {
"id": "019...",
"email": "user@example.com",
"status": "active"
}
}curl http://localhost:8080/api/v1/users/me \
-H "Authorization: Bearer eyJhbG..."All configuration via environment variables. See .env.example.
JWT_SECRET- JWT signing key (min 32 chars)
DB_HOST- PostgreSQL hostDB_PORT- PostgreSQL portDB_USER- Database userDB_PASSWORD- Database passwordDB_NAME- Database name
Set OAUTH_ENABLED=true and configure providers:
OAUTH_GOOGLE_ENABLED=true
OAUTH_GOOGLE_CLIENT_ID=xxx
OAUTH_GOOGLE_CLIENT_SECRET=xxx- Argon2id password hashing
- JWT with short expiry + refresh tokens
- Rate limiting
- Account lockout after failed attempts
- 2FA with TOTP
- Token revocation
- Soft delete
Uses PostgreSQL 18 with native UUIDv7 support.
Tables:
users- Core user datauser_auth- Authentication datauser_oauth- OAuth providersuser_profiles- Profile datauser_preferences- User settingsuser_verification- Email/phone verificationuser_tokens- Temporary tokensroles- Role definitionsuser_roles- User-role assignmentsrefresh_tokens- Active sessions
gouserfy/
├── cmd/gouserfy/ # Entry point
├── config/ # Configuration
├── database/ # DB connection & repository
├── handlers/ # HTTP handlers
├── migrations/ # SQL migrations
├── models/ # Data models
├── server/ # HTTP server
├── services/ # Business logic
├── setup.sh # Interactive setup
├── docker-compose.yml
└── Dockerfile
MIT
