https://github.com/michaelrodriguess/auth-service
🔐 Application to handle with authentication of other applications
https://github.com/michaelrodriguess/auth-service
authentication bcrypt gin golang jwt oauth oauth2
Last synced: about 2 months ago
JSON representation
🔐 Application to handle with authentication of other applications
- Host: GitHub
- URL: https://github.com/michaelrodriguess/auth-service
- Owner: michaelrodriguess
- Created: 2025-04-04T14:37:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-04T18:32:45.000Z (10 months ago)
- Last Synced: 2025-10-19T05:46:15.981Z (8 months ago)
- Topics: authentication, bcrypt, gin, golang, jwt, oauth, oauth2
- Language: Go
- Homepage:
- Size: 8.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 🔐 Auth Service
An authentication service built with **Go (Golang)** that provides user registration, login, token validation, and JWT-based authentication. Ideal for applications that need a decoupled authentication module.
## ✨ Features
- ✅ User registration (`/register`)
- ✅ User login (`/login`)
- ✅ Authenticated user info (`/me`)
- ✅ JWT generation and validation
- ✅ Secure credential hashing
- ✅ Middleware for protected routes
- ✅ Docker and Makefile for easy setup
- ✅ Password reset flow
---
## 🛍 Available Routes
### `POST /register`
Registers a new user.
**Example Body:**
```json
{
"email": "email@domain.com",
"password": "123456",
"role": "admin" or "user"
}
```
**Response:**
```json
{
"token": "0CT0LHOIvqzmRTY3aTU5-kkvkeukFiFjoqG5N9FOcFM......",
"email": "email@domain.com",
"role": "admin" or "user"
}
```
---
### `POST /login`
Authenticates a user and returns a JWT.
**Example Body:**
```json
{
"email": "candango@dev.com",
"password": "123456"
}
```
**Response:**
```json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6..."
}
```
---
### `GET /me`
Returns authenticated user data.
**Required Header:**
```http
Authorization: Bearer
```
**Response:**
```json
{
"id": "id",
"email": "email@domain.com",
"role": "admin" or "user",
"created_at": timestamp,
"updated_at": timestamp
}
```
---
## Installation
### Requirements
- Go 1.18 or higher
- Docker
- Make (optional, for ease of use)
## 🐳 Running MongoDB on Docker
```bash
docker-compose up --build -d
```
---
## 🛠️ Makefile Commands
Useful commands for development:
```bash
make run # Run the app locally
make build # Build the project
make test # Run tests (when added)
make lint # Run linter (when configured)
```
## Running the Go Server
```bash
make run
```
---
## ⚙️ Environment Variables
Create a `.env` file with the following content:
```env
PORT=8080
DB_URI=mongodb://mongo:27017/authdb
JWT_SECRET=your_secure_secret_key
```
---
## 📌 Future Roadmap
- [ ] Refresh token support
- [ ] RBAC (Role-based access control)
---
## Developed by
Michael Araujo Rodrigues — [@michaelrodriguess](https://github.com/michaelrodriguess)