OWUOR OUMA/go-auth Public
3 branches
go-auth
README
<img width="1459" height="791" alt="image" src="https://github.com/user-attachments/assets/d2373235-e66d-4afe-af29-5284d80374a8" />

Go Auth

A simple authentication service built with Go, Fiber v3, and GORM — featuring user registration, login, email verification, and password reset, all backed by SQLite and Resend for transactional email, with Oauth support.

  • GoFiber Handlers — routes for register, login, verification, and password reset
  • Auth Service — login, registration, verification, and password reset logic
  • Email Service — sends verification and password reset emails via Resend
  • SQLite — lightweight storage for users (chosen for simplicity)

Features

  • User registration with hashed passwords (bcrypt)
  • Login with credential + email-verification checks
  • Email verification via a one-time token sent through Resend
  • Forgot password / reset password flow with expiring tokens
  • Session-based flash messages for errors (login/signup)

Tech Stack

LayerTech
Web frameworkFiber v3
ORMGORM
DatabaseSQLite
TemplatesDjango templates via gofiber/template/django
EmailResend
Password hashingbcrypt

Project Structure

GO-AUTH/
├── auth/
│   └── auth.go              # Login logic
├── mail/
│   └── email.go             # Resend integration (verification + reset emails)
├── models/
│   └── user.go               # User model, DB connection, token helpers
├── templates/
│   ├── base.django
│   ├── index.django
│   ├── login.django
│   ├── forgot-password.django
│   └── reset-password.django
├── .env                       # RESEND_API_KEY
├── go.mod
├── go.sum
├── main.go                    # Routes and app setup
└── users.db                   # SQLite database

Setup

  1. Clone and install dependencies
   go mod tidy
  1. Environment variables — create a .env file in the project root:
   RESEND_API_KEY=re_your_key_here
  1. Run the app
   go run main.go

The server starts on http://localhost:3000.

Routes

MethodPathDescription
GET/Sign up page
POST/registerCreate a new user, send verification email
GET/verifyVerify email via token query param
GET/loginLogin page
POST/signinAuthenticate user
GET/forgot-passwordRequest password reset form
POST/forgot-passwordSend password reset email
GET/reset-password/:tokenReset password form (token in URL path)
POST/reset-password/:tokenSubmit new password

Notes

  • Email verification and password reset tokens expire after 30 minutes.
  • The forgot-password endpoint returns the same response whether or not the email exists, to avoid leaking which emails are registered.
  • Password reset uses a URL path parameter (/reset-password/:token) rather than a hidden form field, so the token travels with the page URL itself.

About

3 branches
No license
Updated about 8 hours ago
Contributors

Languages

Go100%

Clone

https://api.codepinion.co.ke/git/geoffrey-owuor-c7ef57de/go-auth.git
git clone https://api.codepinion.co.ke/git/geoffrey-owuor-c7ef57de/go-auth.git