first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:16:43 +03:00
commit 6d95e27114
97 changed files with 15687 additions and 0 deletions

590
docs/API_ENDPOINTS.md Normal file
View File

@@ -0,0 +1,590 @@
# 🌐 GAuth-Central API Endpoints
## Base URL
```
Local Development: http://localhost:8080
Production: http://your-domain.com
```
## API Version: v1
Base Path: `/v1`
---
## 📍 Endpoints
### Public Endpoints (No Authentication Required)
#### 1. Homepage
```
GET /
Content-Type: text/html
```
**Response:** HTML homepage
---
#### 2. Swagger Documentation
```
GET /docs/index.html
Content-Type: text/html
```
**Response:** Swagger UI
---
### Authentication Endpoints
#### 3. Register User
```
POST /v1/auth/register
Content-Type: application/json
Rate Limit: 3 requests / 5 minutes
```
**Request Body:**
```json
{
"email": "user@example.com",
"password": "SecurePass123!",
"user_name": "username"
}
```
**Response (201):**
```json
{
"message": "User created successfully. Please verify your email.",
"user": {
"id": "uuid",
"email": "user@example.com",
"user_name": "username"
}
}
```
**cURL Example:**
```bash
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"user_name": "username"
}'
```
---
#### 4. Login
```
POST /v1/auth/login
Content-Type: application/json
Rate Limit: 5 requests / 1 minute
```
**Request Body:**
```json
{
"email": "user@example.com",
"password": "SecurePass123!"
}
```
**Response (200):**
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "uuid",
"email": "user@example.com",
"user_name": "username"
}
}
```
**cURL Example:**
```bash
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!"
}'
```
---
#### 5. Email Verification
```
GET /v1/auth/verify-email?token={verification_token}
```
**Query Parameters:**
- `token` (required): Email verification token
**Response (200):**
```json
{
"message": "Email verified successfully"
}
```
**cURL Example:**
```bash
curl -X GET "http://localhost:8080/v1/auth/verify-email?token=abc123xyz"
```
---
#### 6. OAuth Login (Google/GitHub)
```
GET /v1/auth/{provider}
```
**Parameters:**
- `provider`: `google` or `github`
**Example:**
```
http://localhost:8080/v1/auth/google
http://localhost:8080/v1/auth/github
```
**Response:** Redirects to OAuth provider
---
#### 7. OAuth Callback
```
GET /v1/auth/{provider}/callback
```
**Parameters:**
- `provider`: `google` or `github`
**Query Parameters:** (Provided by OAuth provider)
- `code`
- `state`
**Response (200):**
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "uuid",
"email": "user@example.com",
"user_name": "username"
}
}
```
---
#### 8. Refresh Token
```
POST /v1/auth/refresh
Content-Type: application/json
```
**Request Body:**
```json
{
"refresh_token": "eyJhbGciOiJIUzI1NiIs..."
}
```
**Response (200):**
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs..."
}
```
**cURL Example:**
```bash
curl -X POST http://localhost:8080/v1/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "your_refresh_token_here"
}'
```
---
### Protected Endpoints (Authentication Required)
**Note:** All protected endpoints require the `Authorization` header:
```
Authorization: Bearer {access_token}
```
---
#### 9. Get Current User
```
GET /v1/auth/me
Authorization: Bearer {access_token}
```
**Response (200):**
```json
{
"id": "uuid",
"email": "user@example.com",
"user_name": "username",
"email_verified": true,
"created_at": "2026-02-04T00:00:00Z"
}
```
**cURL Example:**
```bash
curl -X GET http://localhost:8080/v1/auth/me \
-H "Authorization: Bearer your_access_token_here"
```
---
#### 10. Validate Token
```
GET /v1/auth/validate
Authorization: Bearer {access_token}
```
**Response (200):**
```json
{
"message": "Token is valid",
"user_id": "uuid",
"email": "user@example.com"
}
```
**cURL Example:**
```bash
curl -X GET http://localhost:8080/v1/auth/validate \
-H "Authorization: Bearer your_access_token_here"
```
---
## 🔒 Authentication Flow
### Standard Email/Password Flow
```
1. Register
POST /v1/auth/register
2. Verify Email
GET /v1/auth/verify-email?token=...
3. Login
POST /v1/auth/login
4. Access Protected Resources
GET /v1/auth/me (with Bearer token)
```
### OAuth Flow
```
1. Initiate OAuth
GET /v1/auth/google (or /github)
2. User authorizes on OAuth provider
3. Callback with code
GET /v1/auth/google/callback?code=...
4. Access Protected Resources
GET /v1/auth/me (with Bearer token)
```
---
## 📝 Error Responses
### Standard Error Format
```json
{
"error": "Error message description"
}
```
### Common Error Codes
| Status Code | Meaning |
|------------|---------|
| 400 | Bad Request - Invalid input |
| 401 | Unauthorized - Invalid or missing token |
| 403 | Forbidden - Valid token but insufficient permissions |
| 404 | Not Found - Resource not found |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
---
## 🚦 Rate Limits
| Endpoint | Limit | Time Window |
|----------|-------|-------------|
| POST /v1/auth/register | 3 requests | 5 minutes |
| POST /v1/auth/login | 5 requests | 1 minute |
| All API endpoints | 100 requests | 1 minute |
**Rate Limit Headers:**
```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1643980800
```
---
## 🔑 Authentication Headers
### Access Token
```
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
```
### CORS Headers
```
Origin: http://localhost:3000
Content-Type: application/json
```
---
## 🌍 CORS Configuration
**Allowed Origins:**
- `http://localhost:3000` (development)
**Allowed Methods:**
- GET, POST, PUT, PATCH, DELETE, OPTIONS
**Allowed Headers:**
- Origin, Content-Type, Accept, Authorization
**Credentials:**
- Enabled (`Access-Control-Allow-Credentials: true`)
---
## 📦 Response Examples
### Successful Response
```json
{
"message": "Operation successful",
"data": { ... }
}
```
### Error Response
```json
{
"error": "Invalid credentials"
}
```
### Validation Error
```json
{
"error": "Validation failed: email is required"
}
```
---
## 🔗 Frontend Integration
### JavaScript/TypeScript Example
```javascript
// Base URL
const API_BASE_URL = 'http://localhost:8080';
// Login
async function login(email, password) {
const response = await fetch(`${API_BASE_URL}/v1/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({ email, password })
});
const data = await response.json();
if (response.ok) {
localStorage.setItem('access_token', data.access_token);
localStorage.setItem('refresh_token', data.refresh_token);
return data;
} else {
throw new Error(data.error);
}
}
// Get Current User (Protected)
async function getCurrentUser() {
const token = localStorage.getItem('access_token');
const response = await fetch(`${API_BASE_URL}/v1/auth/me`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
credentials: 'include'
});
const data = await response.json();
if (response.ok) {
return data;
} else {
throw new Error(data.error);
}
}
// Register
async function register(email, password, username) {
const response = await fetch(`${API_BASE_URL}/v1/auth/register`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({
email,
password,
user_name: username
})
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error);
}
return data;
}
```
### Axios Example
```javascript
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:8080/v1',
withCredentials: true,
headers: {
'Content-Type': 'application/json'
}
});
// Add token to requests
api.interceptors.request.use((config) => {
const token = localStorage.getItem('access_token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
// Login
export const login = (email, password) =>
api.post('/auth/login', { email, password });
// Register
export const register = (email, password, user_name) =>
api.post('/auth/register', { email, password, user_name });
// Get current user
export const getCurrentUser = () =>
api.get('/auth/me');
// Refresh token
export const refreshToken = (refresh_token) =>
api.post('/auth/refresh', { refresh_token });
```
---
## 🧪 Postman Collection
You can import these endpoints into Postman:
**Environment Variables:**
```
base_url: http://localhost:8080
access_token: {{access_token}}
```
**Collection Structure:**
```
GAuth-Central API
├── Public
│ ├── Register
│ ├── Login
│ ├── Verify Email
│ ├── Refresh Token
│ ├── OAuth Google
│ └── OAuth GitHub
└── Protected (Auth Required)
├── Get Current User
└── Validate Token
```
---
## 📚 Additional Resources
- **Swagger Documentation**: http://localhost:8080/docs/index.html
- **API Version**: v1.0
- **Last Updated**: February 4, 2026
---
## ⚡ Quick Start
```bash
# 1. Start the server
go run main.go
# 2. Test with curl
curl http://localhost:8080/
# 3. Register a user
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!","user_name":"testuser"}'
# 4. Login
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!"}'
# 5. Use the token from login response
curl http://localhost:8080/v1/auth/me \
-H "Authorization: Bearer YOUR_TOKEN_HERE"
```
---
💡 **Tip**: Use the Swagger UI at http://localhost:8080/docs/index.html for interactive API testing!

119
docs/BACKEND_ENDPOINT.mb Normal file
View File

@@ -0,0 +1,119 @@
-- Register Yeni Kullanıcı
POST
http://localhost:8080/v1/auth/register
-- Gönderrilen JSON
{
"email":"beyhanod@beyhan.dev",
"password":"1923btO**",
"username":"test yaptim"
}
-- Cevap
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmMDVlZTc0Zi1hYjgzLTQxNzEtYjI3Ny1mZGM0NDZhNjA3YjciLCJlbWFpbCI6ImJleHlzc2hhbm9kQGJleWhhbi5kZXYiLCJwZXJtaXNzaW9ucyI6WyJ1c2VyOnJlYWQiXSwiaXNzIjoiZ2F1dGgtY2VudHJhbCIsImV4cCI6MTc3MDEzMDQ2OCwiaWF0IjoxNzcwMTI5NTY4fQ.Qc5EnE2r-In7hm6-NjP6WX2TKm3MyuM68SwsHYUNJbI",
"email": "bexysshanod@beyhan.dev",
"message": "User created successfully",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmMDVlZTc0Zi1hYjgzLTQxNzEtYjI3Ny1mZGM0NDZhNjA3YjciLCJlbWFpbCI6ImJleHlzc2hhbm9kQGJleWhhbi5kZXYiLCJpc3MiOiJnYXV0aC1jZW50cmFsIiwiZXhwIjoxNzcwNzM0MzY4LCJpYXQiOjE3NzAxMjk1Njh9.JE2UZ6jJti2N2jbExx_TTY5VPSfXKvc2ZGB-Nw_toLQ",
"roles": [
{
"id": 2,
"name": "user",
"description": "Default user role",
"permissions": [
{
"id": 1,
"name": "user:read",
"description": "Can read user data"
}
]
}
],
"user_id": "f05ee74f-ab83-4171-b277-fdc446a607b7",
"username": "test yaptim"
}
-- Login Yeni Kullanıcı
POST
http://localhost:8080/v1/auth/login
-- Gönderrilen JSON
{
"email":"beyhanod@beyhan.dev",
"password":"1923btO**"
}
-- Cevap
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5MWNmMDg2OC1kZjI0LTRiOGYtYjQ5MS03MGQ5ZWI3YTQzNzMiLCJlbWFpbCI6ImJleWhhbm9AYmV5aGFuLmRldiIsInBlcm1pc3Npb25zIjpbInVzZXI6cmVhZCJdLCJpc3MiOiJnYXV0aC1jZW50cmFsIiwiZXhwIjoxNzcwMTMwNjU3LCJpYXQiOjE3NzAxMjk3NTd9.QbsRFn5fr7L4Wc7HCxOs0_zOWWhuceWzPmt20TV5lNI",
"email": "beyhano@beyhan.dev",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5MWNmMDg2OC1kZjI0LTRiOGYtYjQ5MS03MGQ5ZWI3YTQzNzMiLCJlbWFpbCI6ImJleWhhbm9AYmV5aGFuLmRldiIsImlzcyI6ImdhdXRoLWNlbnRyYWwiLCJleHAiOjE3NzA3MzQ1NTcsImlhdCI6MTc3MDEyOTc1N30.wBML1pT9S9i9FtAw3PKmJBMdcobZexWVBTRV5remb_s",
"roles": [
{
"id": 2,
"name": "user",
"description": "Default user role",
"permissions": [
{
"id": 1,
"name": "user:read",
"description": "Can read user data"
}
]
}
],
"user_id": "91cf0868-df24-4b8f-b491-70d9eb7a4373",
"username": "user_91cf0868"
}
-- Refresh Token
POST
http://localhost:8080/v1/auth/refresh
-- Gönderilen JSON
{
"refresh_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5MWNmMDg2OC1kZjI0LTRiOGYtYjQ5MS03MGQ5ZWI3YTQzNzMiLCJlbWFpbCI6ImJleWhhbm9AYmV5aGFuLmRldiIsImlzcyI6ImdhdXRoLWNlbnRyYWwiLCJleHAiOjE3NzA3MzQ2NDUsImlhdCI6MTc3MDEyOTg0NX0.ACDDM20v1u6yjyNrqBnWafjXnrRAAT1-8CvfqSkjTsE"
}
-- Cevap
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5MWNmMDg2OC1kZjI0LTRiOGYtYjQ5MS03MGQ5ZWI3YTQzNzMiLCJlbWFpbCI6ImJleWhhbm9AYmV5aGFuLmRldiIsInBlcm1pc3Npb25zIjpbInVzZXI6cmVhZCJdLCJpc3MiOiJnYXV0aC1jZW50cmFsIiwiZXhwIjoxNzcwMTMxMjYwLCJpYXQiOjE3NzAxMzAzNjB9.BKmZBkL6FPo208mYLeBFMkNOqJ2tsmGXJUN_0bdZFHQ",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5MWNmMDg2OC1kZjI0LTRiOGYtYjQ5MS03MGQ5ZWI3YTQzNzMiLCJlbWFpbCI6ImJleWhhbm9AYmV5aGFuLmRldiIsImlzcyI6ImdhdXRoLWNlbnRyYWwiLCJleHAiOjE3NzA3MzUxNjAsImlhdCI6MTc3MDEzMDM2MH0.tkpcbQ6QmVVXK-r0QgP333X_FrAktVOuh1AJhwvV1BQ"
}
-- Me (Kullanıcı Profili)
GET
http://localhost:8080/v1/auth/me
-- Header
Authorization: Bearer ACCESS_TOKEN_BURAYA
-- Body: YOK (GET isteği)
-- Cevap
{
"id": "91cf0868-df24-4b8f-b491-70d9eb7a4373",
"username": "user_91cf0868",
"email": "beyhano@beyhan.dev",
"created_at": "2026-02-03T17:03:07.863425+03:00",
"updated_at": "2026-02-03T17:03:07.880923+03:00",
"social_accounts": null,
"roles": [
{
"id": 2,
"name": "user",
"description": "Default user role",
"permissions": [
{
"id": 1,
"name": "user:read",
"description": "Can read user data"
}
]
}
]
}
-- Validate Token (Token Doğrulama)
GET
http://localhost:8080/v1/auth/validate
-- Header
Authorization: Bearer ACCESS_TOKEN_BURAYA
-- Body: YOK (GET isteği, body gönderilmez)
-- Cevap
{
"email": "beyhano@beyhan.dev",
"message": "Token is valid",
"user_id": "91cf0868-df24-4b8f-b491-70d9eb7a4373"
}

237
docs/BACKEND_URLS.md Normal file
View File

@@ -0,0 +1,237 @@
🔗 Backend URL Yönetimi
API Endpoint Listesi
Base URL
Local: http://localhost:8080
Production: https://api.yourdomain.com
API Version
v1
📋 Tüm Endpoint'ler
Method Endpoint Auth Rate Limit Açıklama
GET / ❌ - Homepage
GET /docs/index.html ❌ - Swagger UI
POST /v1/auth/register ❌ 3/5min Kullanıcı kaydı
POST /v1/auth/login ❌ 5/1min Giriş
GET /v1/auth/verify-email ❌ - Email doğrulama
GET /v1/auth/:provider ❌ - OAuth başlat
GET /v1/auth/:provider/callback ❌ - OAuth callback
POST /v1/auth/refresh ❌ - Token yenile
GET /v1/auth/me ✅ - Kullanıcı bilgileri
GET /v1/auth/validate ✅ - Token doğrula
Admin - User Management (Admin rolü gerekli)
Method Endpoint Auth Açıklama
GET /v1/admin/users ✅ Admin Tüm kullanıcıları listele
GET /v1/admin/users/search?q={query} ✅ Admin Kullanıcı ara
GET /v1/admin/users/:id ✅ Admin Kullanıcı detayı
POST /v1/admin/users ✅ Admin Yeni kullanıcı oluştur
PUT /v1/admin/users/:id ✅ Admin Kullanıcı güncelle
DELETE /v1/admin/users/:id ✅ Admin Kullanıcı sil
POST /v1/admin/users/:id/roles ✅ Admin Rol ata
DELETE /v1/admin/users/:id/roles/:role ✅ Admin Rol kaldır
Admin - Settings (Admin rolü gerekli)
Method Endpoint Auth Açıklama
GET /v1/settings/cors/whitelist ✅ Admin CORS whitelist listele
POST /v1/settings/cors/whitelist ✅ Admin CORS whitelist ekle
PUT /v1/settings/cors/whitelist/:id ✅ Admin CORS whitelist güncelle
DELETE /v1/settings/cors/whitelist/:id ✅ Admin CORS whitelist sil
GET /v1/settings/cors/blacklist ✅ Admin CORS blacklist listele
POST /v1/settings/cors/blacklist ✅ Admin CORS blacklist ekle
PUT /v1/settings/cors/blacklist/:id ✅ Admin CORS blacklist güncelle
DELETE /v1/settings/cors/blacklist/:id ✅ Admin CORS blacklist sil
GET /v1/settings/ratelimit ✅ Admin Rate limit ayarları
PUT /v1/settings/ratelimit/:id ✅ Admin Rate limit güncelle
🎯 Frontend için URL Yapısı
JavaScript/TypeScript Constants
// config/api.js
export const API_CONFIG = {
BASE_URL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080',
API_VERSION: 'v1',
ENDPOINTS: {
// Auth endpoints
REGISTER: '/auth/register',
LOGIN: '/auth/login',
LOGOUT: '/auth/logout',
REFRESH: '/auth/refresh',
VERIFY_EMAIL: '/auth/verify-email',
ME: '/auth/me',
VALIDATE: '/auth/validate',
// OAuth endpoints
OAUTH_GOOGLE: '/auth/google',
OAUTH_GITHUB: '/auth/github',
OAUTH_GOOGLE_CALLBACK: '/auth/google/callback',
OAUTH_GITHUB_CALLBACK: '/auth/github/callback',
}
};
// Helper function
export function getApiUrl(endpoint) {
return `${API_CONFIG.BASE_URL}/${API_CONFIG.API_VERSION}${endpoint}`;
}
// Usage
const loginUrl = getApiUrl(API_CONFIG.ENDPOINTS.LOGIN);
// Result: http://localhost:8080/v1/auth/login
📦 Kullanım Örnekleri
1. React/Next.js
// lib/api.js
const API_BASE = 'http://localhost:8080/v1';
export const authAPI = {
register: (data) =>
fetch(`${API_BASE}/auth/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify(data)
}),
login: (data) =>
fetch(`${API_BASE}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify(data)
}),
getCurrentUser: (token) =>
fetch(`${API_BASE}/auth/me`, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
credentials: 'include'
})
};
2. Vue.js/Nuxt
// plugins/api.js
export default defineNuxtPlugin(() => {
const config = useRuntimeConfig();
const baseURL = config.public.apiBase || 'http://localhost:8080/v1';
return {
provide: {
api: {
auth: {
register: (data) => $fetch(`${baseURL}/auth/register`, {
method: 'POST',
body: data,
credentials: 'include'
}),
login: (data) => $fetch(`${baseURL}/auth/login`, {
method: 'POST',
body: data,
credentials: 'include'
}),
me: () => $fetch(`${baseURL}/auth/me`, {
credentials: 'include'
})
}
}
}
};
});
3. Axios Instance
// lib/axios.js
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:8080/v1',
withCredentials: true,
headers: {
'Content-Type': 'application/json'
}
});
// Add auth token to requests
api.interceptors.request.use((config) => {
const token = localStorage.getItem('access_token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
// Handle 401 errors
api.interceptors.response.use(
(response) => response,
async (error) => {
if (error.response?.status === 401) {
// Try to refresh token
const refreshToken = localStorage.getItem('refresh_token');
if (refreshToken) {
try {
const { data } = await api.post('/auth/refresh', {
refresh_token: refreshToken
});
localStorage.setItem('access_token', data.access_token);
// Retry original request
error.config.headers.Authorization = `Bearer ${data.access_token}`;
return api.request(error.config);
} catch {
// Refresh failed, logout
localStorage.clear();
window.location.href = '/login';
}
}
}
return Promise.reject(error);
}
);
export default api;
🔐 Environment Variables
.env.local (Frontend)
# Development
NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_API_VERSION=v1
# Production
# NEXT_PUBLIC_API_URL=https://api.yourdomain.com
# NEXT_PUBLIC_API_VERSION=v1
.env (Backend)
PORT=8080
CLIENT_CALLBACK_URL=http://localhost:8080/v1/auth
APP_URL=http://localhost:8080
🧪 Test Komutları
# Register
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!","user_name":"test"}'
# Login
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!"}'
# Get user (with token)
curl http://localhost:8080/v1/auth/me \
-H "Authorization: Bearer YOUR_TOKEN"
# Admin - Update user
curl -X PUT http://localhost:8080/v1/admin/users/54687716-1aed-41ff-aa13-bb05dd7f34e7 \
-H "Authorization: Bearer ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "newemail@example.com",
"user_name": "newusername",
"email_verified": true
}'
# Admin - Get all users
curl -X GET http://localhost:8080/v1/admin/users?page=1&limit=10 \
-H "Authorization: Bearer ADMIN_TOKEN"
# Admin - Search users
curl -X GET "http://localhost:8080/v1/admin/users/search?q=test" \
-H "Authorization: Bearer ADMIN_TOKEN"
📚 Swagger Dokümantasyonu
Tüm endpoint'lerin detaylı dokümantasyonu için:
http://localhost:8080/docs/index.html
✅ Hazır Kullanım
API endpoint'leri hazır ve çalışıyor! Frontend'inizde kullanmaya başlayabilirsiniz:
API_ENDPOINTS.md - Detaylı endpoint dokümantasyonu
Swagger UI - İnteraktif API testi: http://localhost:8080/docs/index.html
Yukarıdaki örnekleri projenize kopyalayıp kullanabilirsiniz
Önemli: CORS zaten http://localhost:3000 için yapılandırılmış durumda! ✅

119
docs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,119 @@
# Changelog
All notable changes to this project will be documented in this file.
## [1.1.0] - 2026-02-04
### Added
-**Redis Integration**: Full Redis caching and session management
- Session storage with Redis
- User data caching
- Token blacklist for logout
- Email verification token cache
- Password reset token cache
-**Cache Service**: New dedicated cache service (`internal/services/cache_service.go`)
- SetUser/GetUser/DeleteUser for user caching
- Session management methods
- Rate limiting support
- Token blacklist operations
- Email verification and password reset token management
-**Rate Limiting**: API rate limiting with Redis backend
- Login rate limiting: 5 attempts per minute
- Registration rate limiting: 3 attempts per 5 minutes
- General API rate limiting: 100 requests per minute
- Graceful degradation when Redis is unavailable
-**CORS Configuration**: Cross-Origin Resource Sharing support
- Configurable allowed origins
- Credentials support
- Multiple HTTP methods allowed
-**Docker Compose**: Complete Docker setup with 3 services
- PostgreSQL 17 Alpine
- Redis 7 Alpine with persistence
- Application service with auto-restart
-**Documentation**:
- README.md with comprehensive project documentation
- SETUP.md with detailed setup instructions
- .env.example template file
- Quick start script (start-with-docker.sh)
### Changed
- 🔄 Updated `main.go` to initialize Redis connection
- 🔄 Updated routes to include rate limiting middlewares
- 🔄 Enhanced docker-compose.yml with Redis service
### Technical Details
- **Redis Client**: go-redis/v9
- **CORS Middleware**: gin-contrib/cors
- **Default CORS Origin**: http://localhost:3000
- **Redis Connection**: Gracefully handles unavailability
## [1.0.0] - Initial Release
### Added
- JWT-based authentication
- OAuth2 integration (Google, GitHub)
- Email verification
- PostgreSQL database with GORM
- Swagger/OpenAPI documentation
- User roles and permissions
- Password hashing with bcrypt
- Protected routes with middleware
- Auto-migration and seeding
### Database Models
- Users table with email verification
- Social accounts for OAuth
- Roles and permissions system
- User-Role relationships
### API Endpoints
- POST /v1/auth/register - User registration
- POST /v1/auth/login - User login
- GET /v1/auth/verify-email - Email verification
- POST /v1/auth/refresh - Token refresh
- GET /v1/auth/:provider - OAuth login
- GET /v1/auth/:provider/callback - OAuth callback
- GET /v1/auth/me - Get current user (protected)
- GET /v1/auth/validate - Validate token (protected)
---
## Future Roadmap
### Planned Features
- [ ] Email service integration (SMTP)
- [ ] Password reset functionality
- [ ] 2FA (Two-Factor Authentication)
- [ ] User profile management
- [ ] Admin dashboard
- [ ] Audit logging
- [ ] Metrics and monitoring (Prometheus)
- [ ] API versioning
- [ ] Webhook support
- [ ] Multi-tenancy support
### Performance Improvements
- [ ] Database query optimization
- [ ] Redis clustering support
- [ ] Connection pooling enhancements
- [ ] Response compression
### Security Enhancements
- [ ] IP whitelisting
- [ ] Advanced rate limiting (per user, per endpoint)
- [ ] Brute force protection
- [ ] Session management dashboard
- [ ] Security headers middleware
- [ ] CSP (Content Security Policy)
---
## Version History
- **v1.1.0** - Redis integration, CORS, Rate limiting, Complete documentation
- **v1.0.0** - Initial release with basic authentication and OAuth

406
docs/DEPLOYMENT.md Normal file
View File

@@ -0,0 +1,406 @@
# 🚀 GAuth-Central Deployment Rehberi
## 📋 Deployment Senaryoları
### Senaryo 1: Standalone Deployment (Mevcut Sunucularla)
Bu senaryoda mevcut PostgreSQL ve Redis sunucularınızı kullanıyorsunuz.
#### Ön Gereksinimler
- ✅ PostgreSQL 17+ sunucusu çalışıyor
- ✅ Redis 7+ sunucusu çalışıyor
- ✅ Go 1.23+ yüklü
- ✅ Sunuculara network erişimi var
#### Adımlar
1. **Repository'yi klonlayın**
```bash
git clone <repository-url>
cd AuthCentral
```
2. **.env dosyasını yapılandırın**
```bash
# .env dosyasını oluşturun
cp .env.example .env
# Düzenleyin
nano .env
```
**.env içeriği:**
```env
PORT=8080
# Mevcut PostgreSQL sunucunuz
DB_URL="host=10.80.80.70 user=cloud password=xxx dbname=go_gauth port=5432 sslmode=disable TimeZone=Europe/Istanbul"
DB_USER=cloud
DB_PASSWORD=xxx
DB_NAME=go_gauth
DB_PORT=5432
DB_HOST=10.80.80.70
# Mevcut Redis sunucunuz
REDIS_HOST=10.80.80.70
REDIS_PORT=6379
REDIS_USER=default
REDIS_PASSWORD=xxx
REDIS_URL=redis://default:xxx@10.80.80.70:6379/0
# JWT Secret (production için güçlü bir değer)
JWT_SECRET=super_secure_production_secret_key_change_this
# OAuth Credentials
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
CLIENT_CALLBACK_URL=http://your-domain.com/v1/auth
APP_URL=http://your-domain.com
```
3. **Bağımlılıkları yükleyin**
```bash
go mod download
```
4. **Bağlantıları test edin**
```bash
# PostgreSQL bağlantısı
PGPASSWORD=xxx psql -h 10.80.80.70 -U cloud -d go_gauth -c "SELECT version();"
# Redis bağlantısı
redis-cli -h 10.80.80.70 -p 6379 -a xxx --no-auth-warning PING
```
5. **Uygulamayı başlatın**
```bash
# Quick start script ile
./start.sh
# veya systemd service olarak (aşağıya bakın)
```
---
### Senaryo 2: Docker Compose Deployment
Tüm servisleri (PostgreSQL, Redis, App) Docker ile çalıştırma.
#### Adımlar
1. **Repository'yi klonlayın**
```bash
git clone <repository-url>
cd AuthCentral
```
2. **.env dosyasını yapılandırın**
```bash
cp .env.example .env
nano .env
```
3. **Docker Compose ile başlatın**
```bash
docker-compose up -d
```
4. **Logları kontrol edin**
```bash
docker-compose logs -f app
```
5. **Durum kontrolü**
```bash
docker-compose ps
curl http://localhost:8080/
```
---
### Senaryo 3: Production Deployment (Systemd)
Production ortamında systemd ile çalıştırma.
#### 1. Systemd Service Dosyası Oluşturun
```bash
sudo nano /etc/systemd/system/gauth-central.service
```
**gauth-central.service:**
```ini
[Unit]
Description=GAuth-Central Authentication Service
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/gauth-central
EnvironmentFile=/opt/gauth-central/.env
ExecStart=/opt/gauth-central/main
Restart=always
RestartSec=5
StandardOutput=append:/var/log/gauth-central/app.log
StandardError=append:/var/log/gauth-central/error.log
# Security
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
#### 2. Log Dizinini Oluşturun
```bash
sudo mkdir -p /var/log/gauth-central
sudo chown www-data:www-data /var/log/gauth-central
```
#### 3. Uygulamayı Deploy Edin
```bash
# Deployment dizinine kopyalayın
sudo mkdir -p /opt/gauth-central
sudo cp -r . /opt/gauth-central/
cd /opt/gauth-central
# Build edin
go build -o main .
# İzinleri ayarlayın
sudo chown -R www-data:www-data /opt/gauth-central
sudo chmod +x /opt/gauth-central/main
```
#### 4. Service'i Başlatın
```bash
sudo systemctl daemon-reload
sudo systemctl enable gauth-central
sudo systemctl start gauth-central
sudo systemctl status gauth-central
```
#### 5. Logları İzleyin
```bash
# Real-time logs
sudo journalctl -u gauth-central -f
# Son 100 satır
sudo journalctl -u gauth-central -n 100
# Application logs
tail -f /var/log/gauth-central/app.log
```
---
## 🔒 Production Checklist
### Güvenlik
- [ ] JWT_SECRET güçlü bir değer olarak ayarlandı
- [ ] PostgreSQL şifreleri güçlü
- [ ] Redis şifre koruması aktif
- [ ] SSL/TLS sertifikaları yapılandırıldı (Nginx/Caddy ile)
- [ ] CORS AllowOrigins production domain'lere güncellendi
- [ ] Firewall kuralları ayarlandı
- [ ] PostgreSQL sslmode=require (production)
- [ ] Rate limiting limitleri gözden geçirildi
### Performance
- [ ] PostgreSQL connection pooling ayarları
- [ ] Redis max memory policy ayarlandı
- [ ] Log rotation yapılandırıldı
- [ ] Monitoring kuruldu (Prometheus/Grafana)
- [ ] Health check endpoint'i aktif
### Backup
- [ ] PostgreSQL otomatik backup
- [ ] Redis persistence yapılandırması
- [ ] Backup restore testi yapıldı
### Monitoring
- [ ] Application logs toplanıyor
- [ ] Error tracking (Sentry vb.)
- [ ] Uptime monitoring
- [ ] Resource monitoring (CPU, RAM, Disk)
---
## 🌐 Nginx Reverse Proxy
Production'da Nginx kullanarak SSL termination:
```nginx
server {
listen 80;
server_name api.yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name api.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/api.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.yourdomain.com/privkey.pem;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
```
---
## 📊 Health Checks
### Application Health Check
```bash
curl http://localhost:8080/
```
### PostgreSQL Health
```bash
PGPASSWORD=xxx psql -h 10.80.80.70 -U cloud -d go_gauth -c "SELECT 1;"
```
### Redis Health
```bash
redis-cli -h 10.80.80.70 -p 6379 -a xxx --no-auth-warning PING
```
---
## 🔄 Update/Rollback Prosedürü
### Update
```bash
cd /opt/gauth-central
# Backup
sudo cp main main.backup
# Pull updates
git pull
# Build
go build -o main .
# Restart service
sudo systemctl restart gauth-central
# Check status
sudo systemctl status gauth-central
# Check logs
sudo journalctl -u gauth-central -f
```
### Rollback
```bash
cd /opt/gauth-central
# Restore backup
sudo cp main.backup main
# Restart
sudo systemctl restart gauth-central
```
---
## 🐛 Troubleshooting
### Service başlamıyor
```bash
# Logs kontrol
sudo journalctl -u gauth-central -n 50
# Config kontrol
cat /opt/gauth-central/.env
# Permissions kontrol
ls -la /opt/gauth-central/main
```
### PostgreSQL bağlantı hatası
```bash
# Bağlantı testi
PGPASSWORD=xxx psql -h HOST -U USER -d DB -c "SELECT 1;"
# Network kontrolü
telnet HOST 5432
```
### Redis bağlantı hatası
```bash
# Redis testi
redis-cli -h HOST -p PORT -a PASSWORD PING
# Network kontrolü
telnet HOST 6379
```
---
## 📝 Environment Variables Reference
| Variable | Required | Example | Description |
|----------|----------|---------|-------------|
| `PORT` | Yes | `8080` | Application port |
| `DB_URL` | Yes | `host=...` | PostgreSQL connection string |
| `REDIS_URL` | Yes | `redis://...` | Redis connection URL |
| `JWT_SECRET` | Yes | `secret123` | JWT signing key |
| `GOOGLE_CLIENT_ID` | No | `xxx.apps.googleusercontent.com` | Google OAuth |
| `GITHUB_CLIENT_ID` | No | `Ov23li...` | GitHub OAuth |
| `CLIENT_CALLBACK_URL` | Yes | `http://localhost:8080/v1/auth` | OAuth callback base URL |
| `APP_URL` | Yes | `http://localhost:8080` | Application URL |
---
## 🎯 Next Steps
1. Setup monitoring (Prometheus + Grafana)
2. Configure log aggregation (ELK Stack)
3. Setup automated backups
4. Configure CI/CD pipeline
5. Setup staging environment
6. Configure load balancing (if needed)
---
💡 **Pro Tip**: Her deployment öncesi staging ortamında test edin!

166
docs/QUICKSTART.txt Normal file
View File

@@ -0,0 +1,166 @@
╔═══════════════════════════════════════════════════════════════════════╗
║ 🚀 GAuth-Central Quick Start ║
╚═══════════════════════════════════════════════════════════════════════╝
┌─────────────────────────────────────────────────────────────────────┐
│ 🎯 HIZLI BAŞLATMA │
└─────────────────────────────────────────────────────────────────────┘
Standalone Mode (Mevcut Sunucularla):
────────────────────────────────────────
$ ./start.sh
Docker Mode (Tüm Servisler):
────────────────────────────
$ ./start-with-docker.sh
Manuel:
───────
$ go run main.go
┌─────────────────────────────────────────────────────────────────────┐
│ 🌐 ERİŞİM NOKTALARI │
└─────────────────────────────────────────────────────────────────────┘
API: http://localhost:8080
Swagger: http://localhost:8080/docs/index.html
Frontend: http://localhost:3000 (CORS enabled)
┌─────────────────────────────────────────────────────────────────────┐
│ 🔧 MEVCUT YAPILANDIRMA │
└─────────────────────────────────────────────────────────────────────┘
PostgreSQL: 10.80.80.70:5432/go_gauth (user: cloud)
Redis: 10.80.80.70:6379 (user: default)
Backend: localhost:8080
┌─────────────────────────────────────────────────────────────────────┐
│ 🧪 TEST KOMUTLARI │
└─────────────────────────────────────────────────────────────────────┘
Sağlık Kontrolü:
────────────────
$ curl http://localhost:8080/
PostgreSQL Test:
────────────────
$ PGPASSWORD=gg7678290 psql -h 10.80.80.70 -U cloud \
-d go_gauth -c "SELECT 1;"
Redis Test:
───────────
$ redis-cli -h 10.80.80.70 -p 6379 -a gg7678290 \
--no-auth-warning PING
Kullanıcı Kaydı:
────────────────
$ curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Pass123!",
"user_name":"test"}'
┌─────────────────────────────────────────────────────────────────────┐
│ 📚 DOKÜMANTASYON │
└─────────────────────────────────────────────────────────────────────┘
README.md - Genel bilgiler ve özellikler
SETUP.md - Detaylı kurulum rehberi (4 seçenek)
DEPLOYMENT.md - Production deployment rehberi
QUICK_REFERENCE.md - Komutlar ve örnekler
CHANGELOG.md - Versiyon geçmişi
┌─────────────────────────────────────────────────────────────────────┐
│ ✨ ÖNE ÇIKAN ÖZELLİKLER │
└─────────────────────────────────────────────────────────────────────┘
✅ CORS yapılandırması (localhost:3000)
✅ Redis cache & session management
✅ Rate limiting (Login: 5/min, Register: 3/5min)
✅ JWT authentication
✅ OAuth2 (Google, GitHub)
✅ Email verification
✅ PostgreSQL + GORM
✅ Swagger documentation
✅ Docker support
┌─────────────────────────────────────────────────────────────────────┐
│ 🔐 GÜVENLİK ÖZELLİKLERİ │
└─────────────────────────────────────────────────────────────────────┘
• Bcrypt password hashing
• JWT token authentication
• Rate limiting (brute force protection)
• Token blacklist (logout)
• CORS policy
• Session management with Redis
┌─────────────────────────────────────────────────────────────────────┐
│ 📊 API ENDPOINTS │
└─────────────────────────────────────────────────────────────────────┘
POST /v1/auth/register - Kayıt (rate limited)
POST /v1/auth/login - Giriş (rate limited)
GET /v1/auth/verify-email - Email doğrulama
POST /v1/auth/refresh - Token yenileme
GET /v1/auth/me [Auth] - Kullanıcı bilgileri
GET /v1/auth/validate [Auth] - Token doğrulama
GET /v1/auth/:provider - OAuth (google/github)
┌─────────────────────────────────────────────────────────────────────┐
│ 🛠️ YARARLI KOMUTLAR │
└─────────────────────────────────────────────────────────────────────┘
Build: go build -o main .
Run: ./main
Dev Mode: go run main.go
Swagger Update: swag init -g main.go
Dependencies: go mod tidy
┌─────────────────────────────────────────────────────────────────────┐
│ 📦 SİSTEM GEREKSİNİMLERİ │
└─────────────────────────────────────────────────────────────────────┘
• Go 1.23+
• PostgreSQL 17+ erişimi (10.80.80.70:5432)
• Redis 7+ erişimi (10.80.80.70:6379)
• Network bağlantısı
┌─────────────────────────────────────────────────────────────────────┐
│ 🚨 SORUN GİDERME │
└─────────────────────────────────────────────────────────────────────┘
PostgreSQL bağlanamıyor:
────────────────────────
• .env dosyasında DB_URL kontrol edin
• Network erişimini test edin: telnet 10.80.80.70 5432
• Kullanıcı adı/şifre doğru mu kontrol edin
Redis bağlanamıyor:
──────────────────
• REDIS_URL doğru mu kontrol edin
• Network erişimi: telnet 10.80.80.70 6379
• Redis şifresini kontrol edin
CORS hatası:
────────────
• main.go'da AllowOrigins kontrol edin
• Frontend URL'i http://localhost:3000 mi?
Rate limit:
───────────
• api/middlewares/rate_limit_middleware.go'da
limit değerlerini artırın
┌─────────────────────────────────────────────────────────────────────┐
│ 📞 DAHA FAZLA BİLGİ │
└─────────────────────────────────────────────────────────────────────┘
Tüm detaylar için dokümantasyon dosyalarına bakın:
$ cat README.md
$ cat SETUP.md
$ cat DEPLOYMENT.md
╔═══════════════════════════════════════════════════════════════════════╗
║ 🎉 Başarılı çalışmalar! Sorularınız için dokümantasyona bakın. ║
╚═══════════════════════════════════════════════════════════════════════╝

267
docs/QUICK_REFERENCE.md Normal file
View File

@@ -0,0 +1,267 @@
# 🚀 GAuth-Central - Quick Reference
## 🏃 Hızlı Başlatma
```bash
# Standalone Mode (Mevcut PostgreSQL & Redis ile)
./start.sh
# Docker ile (Tüm servisler)
./start-with-docker.sh
# Manuel
go run main.go
```
## 🔗 Önemli URL'ler
| Servis | URL | Açıklama |
|--------|-----|----------|
| API | http://localhost:8080 | Ana API |
| Swagger | http://localhost:8080/docs/index.html | API Dokümantasyonu |
| PostgreSQL | localhost:5432 | Database |
| Redis | localhost:6379 | Cache |
## 📝 Temel Komutlar
```bash
# Docker Servisleri
docker-compose up -d # Başlat
docker-compose down # Durdur
docker-compose down -v # Durdur + Volume'ları sil
docker-compose logs -f app # Logları izle
docker-compose ps # Servis durumları
# Go Komutları
go run main.go # Çalıştır
go build -o main . # Derle
go mod tidy # Bağımlılıkları temizle
swag init -g main.go # Swagger güncelle
# Redis Komutları
docker exec -it gauth_redis redis-cli
> PING # Bağlantı testi
> KEYS * # Tüm key'leri listele
> GET user:UUID # User cache getir
> DEL session:TOKEN # Session sil
> FLUSHDB # Tüm cache'i temizle
# PostgreSQL Komutları
docker exec -it gauth_postgres psql -U postgres -d gauth
\dt # Tabloları listele
\d users # Users tablosu yapısı
SELECT * FROM roles; # Rolleri listele
SELECT * FROM users LIMIT 10; # Kullanıcıları listele
```
## 🔧 Environment Variables
| Değişken | Varsayılan | Açıklama |
|----------|------------|----------|
| `PORT` | 8080 | Server portu |
| `DB_URL` | - | PostgreSQL bağlantısı |
| `REDIS_URL` | - | Redis bağlantısı |
| `JWT_SECRET` | - | JWT gizli anahtar |
| `GOOGLE_CLIENT_ID` | - | Google OAuth |
| `GITHUB_CLIENT_ID` | - | GitHub OAuth |
## 📡 API Endpoints
### Public Endpoints
```bash
# Register
POST /v1/auth/register
{
"email": "user@example.com",
"password": "SecurePass123!",
"user_name": "username"
}
# Login
POST /v1/auth/login
{
"email": "user@example.com",
"password": "SecurePass123!"
}
# OAuth
GET /v1/auth/google
GET /v1/auth/github
# Verify Email
GET /v1/auth/verify-email?token=...
# Refresh Token
POST /v1/auth/refresh
{
"refresh_token": "..."
}
```
### Protected Endpoints (Requires Authorization Header)
```bash
# Get User Info
GET /v1/auth/me
Authorization: Bearer <token>
# Validate Token
GET /v1/auth/validate
Authorization: Bearer <token>
```
## 🛡️ Rate Limits
| Endpoint | Limit | Süre |
|----------|-------|------|
| `/v1/auth/login` | 5 | 1 dakika |
| `/v1/auth/register` | 3 | 5 dakika |
| Genel API | 100 | 1 dakika |
## 🗄️ Redis Keys
| Pattern | Açıklama | TTL |
|---------|----------|-----|
| `user:{id}` | User cache | 1 saat |
| `session:{token}` | Session data | 24 saat |
| `blacklist:{token}` | Invalidated tokens | 24 saat |
| `ratelimit:{key}` | Rate limit counters | Dinamik |
| `email_verify:{email}` | Email verification | Dinamik |
| `password_reset:{email}` | Password reset | Dinamik |
## 🧪 Test Komutları
```bash
# Health Check
curl http://localhost:8080/
# Register Test
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!","user_name":"testuser"}'
# Login Test
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@test.com","password":"Test123!"}'
# Get User Info (with token)
curl http://localhost:8080/v1/auth/me \
-H "Authorization: Bearer YOUR_TOKEN_HERE"
```
## 🐛 Sorun Giderme
```bash
# Servis durumlarını kontrol et
docker-compose ps
# App loglarını kontrol et
docker-compose logs app
# Redis bağlantısı
docker exec -it gauth_redis redis-cli PING
# PostgreSQL bağlantısı
docker exec -it gauth_postgres pg_isready -U postgres
# Container'ı yeniden başlat
docker-compose restart app
# Tüm servisleri yeniden oluştur
docker-compose down
docker-compose up -d --build
```
## 📊 Database Schema
```sql
-- Users Table
users (
id UUID PRIMARY KEY,
email VARCHAR UNIQUE,
user_name VARCHAR NOT NULL,
password_hash VARCHAR,
email_verified BOOLEAN,
email_verify_token VARCHAR,
created_at TIMESTAMP,
updated_at TIMESTAMP
)
-- Roles Table
roles (
id UUID PRIMARY KEY,
name VARCHAR UNIQUE,
description TEXT
)
-- Permissions Table
permissions (
id UUID PRIMARY KEY,
name VARCHAR UNIQUE,
description TEXT
)
```
## 🔐 CORS Yapılandırması
Varsayılan: `http://localhost:3000`
Değiştirmek için `main.go`:
```go
AllowOrigins: []string{
"http://localhost:3000",
"https://yourdomain.com",
}
```
## 📚 Cache Service Örnekleri
```go
import "gauth-central/internal/services"
cache := services.NewCacheService()
// User caching
cache.SetUser(userID, user, 1*time.Hour)
user, err := cache.GetUser(userID)
// Session
cache.SetSession(token, userID, 24*time.Hour)
userID, err := cache.GetSession(token)
// Rate limiting
count, err := cache.IncrementRateLimit("login:"+ip, 1*time.Minute)
if count > 5 {
// Rate limit exceeded
}
// Token blacklist
cache.BlacklistToken(token, 24*time.Hour)
isBlacklisted, err := cache.IsTokenBlacklisted(token)
```
## 🎯 Önemli Dosyalar
| Dosya | Açıklama |
|-------|----------|
| `main.go` | Ana uygulama |
| `config/config.go` | Yapılandırma |
| `internal/database/redis.go` | Redis bağlantısı |
| `internal/services/cache_service.go` | Cache servisi |
| `api/routes/routes.go` | Route tanımları |
| `api/middlewares/rate_limit_middleware.go` | Rate limiting |
| `docker-compose.yml` | Docker yapılandırması |
| `.env` | Environment variables |
## 📖 Dokümantasyon
- `README.md` - Genel proje bilgisi
- `SETUP.md` - Detaylı kurulum rehberi
- `CHANGELOG.md` - Versiyon geçmişi
- `QUICK_REFERENCE.md` - Bu dosya
---
💡 **İpucu**: Swagger UI'da tüm endpoint'leri test edebilirsiniz: http://localhost:8080/docs/index.html

558
docs/SETTINGS_API.md Normal file
View File

@@ -0,0 +1,558 @@
# 🔧 CORS & Rate Limit Yönetim API'si
## Yeni Endpoint'ler
### Base URL
```
http://localhost:8080/v1/settings
```
**Not:** Tüm settings endpoint'leri authentication gerektirir (Bearer token).
---
## 📋 CORS Whitelist Yönetimi
### 1. Tüm Whitelist Kayıtlarını Getir
```
GET /v1/settings/cors/whitelist
Authorization: Bearer {token}
```
**Response:**
```json
[
{
"id": "uuid",
"origin": "http://localhost:3000",
"description": "Default local frontend",
"is_active": true,
"created_by": "system",
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
}
]
```
### 2. Yeni Whitelist Ekle
```
POST /v1/settings/cors/whitelist
Authorization: Bearer {token}
Content-Type: application/json
```
**Request Body:**
```json
{
"origin": "https://example.com",
"description": "Production frontend"
}
```
**Response (201):**
```json
{
"id": "uuid",
"origin": "https://example.com",
"description": "Production frontend",
"is_active": true,
"created_by": "user@example.com",
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
}
```
### 3. Whitelist Güncelle
```
PUT /v1/settings/cors/whitelist/{id}
Authorization: Bearer {token}
Content-Type: application/json
```
**Request Body:**
```json
{
"origin": "https://newdomain.com",
"description": "Updated description",
"is_active": false
}
```
**Response (200):**
```json
{
"message": "Whitelist updated successfully"
}
```
### 4. Whitelist Sil
```
DELETE /v1/settings/cors/whitelist/{id}
Authorization: Bearer {token}
```
**Response (200):**
```json
{
"message": "Whitelist entry deleted successfully"
}
```
---
## 🚫 CORS Blacklist Yönetimi
### 1. Tüm Blacklist Kayıtlarını Getir
```
GET /v1/settings/cors/blacklist
Authorization: Bearer {token}
```
**Response:**
```json
[
{
"id": "uuid",
"origin": "http://malicious-site.com",
"reason": "Security threat",
"is_active": true,
"created_by": "admin@example.com",
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
}
]
```
### 2. Yeni Blacklist Ekle
```
POST /v1/settings/cors/blacklist
Authorization: Bearer {token}
Content-Type: application/json
```
**Request Body:**
```json
{
"origin": "http://spam-site.com",
"reason": "Spam attempts detected"
}
```
**Response (201):**
```json
{
"id": "uuid",
"origin": "http://spam-site.com",
"reason": "Spam attempts detected",
"is_active": true,
"created_by": "user@example.com",
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
}
```
### 3. Blacklist Güncelle
```
PUT /v1/settings/cors/blacklist/{id}
Authorization: Bearer {token}
Content-Type: application/json
```
**Request Body:**
```json
{
"origin": "http://updated-domain.com",
"reason": "Updated reason",
"is_active": true
}
```
**Response (200):**
```json
{
"message": "Blacklist updated successfully"
}
```
### 4. Blacklist Sil
```
DELETE /v1/settings/cors/blacklist/{id}
Authorization: Bearer {token}
```
**Response (200):**
```json
{
"message": "Blacklist entry deleted successfully"
}
```
---
## ⚡ Rate Limit Ayarları Yönetimi
### 1. Tüm Rate Limit Ayarlarını Getir
```
GET /v1/settings/ratelimit
Authorization: Bearer {token}
```
**Response:**
```json
[
{
"id": "uuid",
"name": "login",
"description": "Login endpoint rate limit",
"max_requests": 5,
"window_seconds": 60,
"is_active": true,
"updated_by": "admin@example.com",
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
},
{
"id": "uuid",
"name": "register",
"description": "Registration endpoint rate limit",
"max_requests": 3,
"window_seconds": 300,
"is_active": true,
"updated_by": null,
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
},
{
"id": "uuid",
"name": "api",
"description": "General API rate limit",
"max_requests": 100,
"window_seconds": 60,
"is_active": true,
"updated_by": null,
"created_at": "2026-02-04T00:00:00Z",
"updated_at": "2026-02-04T00:00:00Z"
}
]
```
### 2. Rate Limit Ayarını Güncelle
```
PUT /v1/settings/ratelimit/{id}
Authorization: Bearer {token}
Content-Type: application/json
```
**Request Body:**
```json
{
"max_requests": 10,
"window_seconds": 120,
"description": "Updated rate limit",
"is_active": true
}
```
**Response (200):**
```json
{
"message": "Rate limit setting updated successfully"
}
```
---
## 🔄 Çalışma Mantığı
### CORS Kontrolü
1. **Request gelir** → Origin header okunur
2. **Blacklist kontrolü** → Origin blacklist'te var mı?
- Varsa → **403 Forbidden**
3. **Whitelist kontrolü** → Origin whitelist'te var mı?
- Varsa → **İzin ver**
- Yoksa → **403 Forbidden**
### Cache Stratejisi
- **Whitelist/Blacklist**: 1 saat cache
- **Rate Limit Settings**: 1 saat cache
- Her CRUD işleminden sonra ilgili cache **invalidate** edilir
- Database'den tekrar okunur ve cache'lenir
### Rate Limiting
1. **Database'den ayarlar okunur** (cache'den veya DB'den)
2. **IP bazlı sayaç** Redis'te tutulur
3. **Limit aşılırsa****429 Too Many Requests**
---
## 📝 Kullanım Örnekleri
### JavaScript/TypeScript
```javascript
const API_BASE = 'http://localhost:8080/v1/settings';
const token = localStorage.getItem('access_token');
// Whitelist'e yeni origin ekle
async function addToWhitelist(origin, description) {
const response = await fetch(`${API_BASE}/cors/whitelist`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ origin, description })
});
return response.json();
}
// Rate limit ayarlarını getir
async function getRateLimits() {
const response = await fetch(`${API_BASE}/ratelimit`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
return response.json();
}
// Rate limit güncelle
async function updateRateLimit(id, maxRequests, windowSeconds) {
const response = await fetch(`${API_BASE}/ratelimit/${id}`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
max_requests: maxRequests,
window_seconds: windowSeconds
})
});
return response.json();
}
// Blacklist'e ekle
async function addToBlacklist(origin, reason) {
const response = await fetch(`${API_BASE}/cors/blacklist`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ origin, reason })
});
return response.json();
}
```
### cURL Örnekleri
```bash
# Token al (önce login)
TOKEN="your_access_token_here"
# Whitelist'i görüntüle
curl -X GET http://localhost:8080/v1/settings/cors/whitelist \
-H "Authorization: Bearer $TOKEN"
# Yeni origin ekle
curl -X POST http://localhost:8080/v1/settings/cors/whitelist \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"origin": "https://myapp.com",
"description": "Production app"
}'
# Whitelist güncelle
curl -X PUT http://localhost:8080/v1/settings/cors/whitelist/UUID_HERE \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"is_active": false
}'
# Blacklist'e ekle
curl -X POST http://localhost:8080/v1/settings/cors/blacklist \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"origin": "http://bad-site.com",
"reason": "Security threat"
}'
# Rate limit ayarlarını görüntüle
curl -X GET http://localhost:8080/v1/settings/ratelimit \
-H "Authorization: Bearer $TOKEN"
# Rate limit güncelle
curl -X PUT http://localhost:8080/v1/settings/ratelimit/UUID_HERE \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"max_requests": 20,
"window_seconds": 60,
"description": "Updated login limit"
}'
```
---
## 🗄️ Database Tabloları
### cors_whitelists
```sql
CREATE TABLE cors_whitelists (
id UUID PRIMARY KEY,
origin VARCHAR(255) UNIQUE NOT NULL,
description TEXT,
is_active BOOLEAN DEFAULT true,
created_by VARCHAR(255),
created_at TIMESTAMP,
updated_at TIMESTAMP
);
```
### cors_blacklists
```sql
CREATE TABLE cors_blacklists (
id UUID PRIMARY KEY,
origin VARCHAR(255) UNIQUE NOT NULL,
reason TEXT,
is_active BOOLEAN DEFAULT true,
created_by VARCHAR(255),
created_at TIMESTAMP,
updated_at TIMESTAMP
);
```
### rate_limit_settings
```sql
CREATE TABLE rate_limit_settings (
id UUID PRIMARY KEY,
name VARCHAR(100) UNIQUE NOT NULL,
description TEXT,
max_requests BIGINT NOT NULL,
window_seconds INTEGER NOT NULL,
is_active BOOLEAN DEFAULT true,
updated_by VARCHAR(255),
created_at TIMESTAMP,
updated_at TIMESTAMP
);
```
---
## ⚙️ Default Ayarlar
Uygulama ilk kez başlatıldığında otomatik olarak şu ayarlar oluşturulur:
### CORS Whitelist
- `http://localhost:3000` - Default local frontend
- `http://localhost:8080` - Backend self
### Rate Limit Settings
- **login**: 5 istek / 60 saniye
- **register**: 3 istek / 300 saniye
- **api**: 100 istek / 60 saniye
---
## 🔐 Güvenlik Notları
1. **Authentication Zorunlu**: Tüm settings endpoint'leri authentication gerektirir
2. **Admin Kontrolü**: Şu anda tüm authenticated kullanıcılar yönetebilir (TODO: Admin role check eklenecek)
3. **Cache**: Değişiklikler 1 saat boyunca cache'de kalır
4. **Blacklist Önceliği**: Blacklist kontrolü whitelist'ten önce yapılır
---
## 📊 Frontend Admin Panel Örneği
```javascript
// Admin Panel Component
class CorsManagement {
constructor() {
this.api = 'http://localhost:8080/v1/settings';
this.token = localStorage.getItem('access_token');
}
async getWhitelist() {
const res = await fetch(`${this.api}/cors/whitelist`, {
headers: { 'Authorization': `Bearer ${this.token}` }
});
return res.json();
}
async addWhitelist(origin, description) {
const res = await fetch(`${this.api}/cors/whitelist`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ origin, description })
});
return res.json();
}
async updateWhitelist(id, data) {
const res = await fetch(`${this.api}/cors/whitelist/${id}`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
return res.json();
}
async deleteWhitelist(id) {
const res = await fetch(`${this.api}/cors/whitelist/${id}`, {
method: 'DELETE',
headers: { 'Authorization': `Bearer ${this.token}` }
});
return res.json();
}
}
// Kullanım
const corsManager = new CorsManagement();
// Whitelist listele
corsManager.getWhitelist().then(data => {
console.log('Whitelist:', data);
});
// Yeni ekle
corsManager.addWhitelist('https://myapp.com', 'Production app');
// Güncelle
corsManager.updateWhitelist('uuid-here', { is_active: false });
// Sil
corsManager.deleteWhitelist('uuid-here');
```
---
## ✅ Özet
Artık CORS whitelist/blacklist ve rate limit ayarlarını:
-**Database'de** saklayabiliyorsunuz
-**Redis ile cache**'leyebiliyorsunuz
-**Frontend'den yönetebiliyorsunuz**
-**CRUD işlemleri** yapabiliyorsunuz
-**Dinamik olarak** güncelleyebiliyorsunuz
Tüm ayarlar database'de tutulur, değişiklikler anında Redis cache'ini invalidate eder ve yeni değerler kullanılmaya başlanır!

328
docs/SETUP.md Normal file
View File

@@ -0,0 +1,328 @@
# 🚀 GAuth-Central Kurulum Rehberi
## Hızlı Başlangıç
### Option 1: Standalone Mode (Mevcut Sunucular ile)
Eğer zaten çalışan PostgreSQL ve Redis sunucularınız varsa:
```bash
# 1. .env dosyasını kontrol edin ve sunucu bilgilerini girin
# DB_URL="host=YOUR_HOST user=YOUR_USER password=YOUR_PASS dbname=YOUR_DB..."
# REDIS_URL=redis://user:pass@YOUR_HOST:6379/0
# 2. Uygulamayı başlatın
./start.sh
```
Script şunları yapacaktır:
- ✅ .env dosyasını kontrol eder
- ✅ PostgreSQL bağlantısını test eder
- ✅ Redis bağlantısını test eder
- ✅ Uygulamayı derler ve başlatır
### Option 2: Docker ile (Yeni Kurulum)
```bash
# 1. Start-with-docker scriptini çalıştırın
./start-with-docker.sh
# 2. Logları izleyin
docker-compose logs -f app
```
### Option 2: Docker ile (Yeni Kurulum)
```bash
# 1. Start-with-docker scriptini çalıştırın
./start-with-docker.sh
# 2. Logları izleyin
docker-compose logs -f app
```
### Option 3: Manuel Kurulum (Sadece Uygulama)
**Not:** Bu option mevcut PostgreSQL ve Redis sunucularınızla çalışmak için kullanılır.
#### 1. Bağımlılıkları Yükleyin
```bash
go mod download
```
#### 2. .env Dosyasını Yapılandırın
```bash
# .env dosyasını düzenleyin
nano .env
```
Gerekli ayarlar:
```env
PORT=8080
# Mevcut PostgreSQL sunucunuz
DB_URL="host=10.80.80.70 user=cloud password=xxx dbname=go_gauth port=5432 sslmode=disable TimeZone=Europe/Istanbul"
# Mevcut Redis sunucunuz
REDIS_URL=redis://default:xxx@10.80.80.70:6379/0
# JWT Secret
JWT_SECRET=your_super_secret_key
# OAuth credentials (opsiyonel)
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
CLIENT_CALLBACK_URL=http://localhost:8080/v1/auth
```
#### 3. Uygulamayı Çalıştırın
```bash
# Quick start script ile
./start.sh
# veya manuel
go build -o main .
./main
# veya doğrudan
go run main.go
```
### Option 4: Docker ile Sadece Veritabanları
### Option 4: Docker ile Sadece Veritabanları
Eğer uygulamayı local'de çalıştırıp sadece veritabanlarını Docker'da tutmak isterseniz:
#### 1. PostgreSQL'i Başlatın
```bash
docker run -d \
--name gauth_postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=yourpassword \
-e POSTGRES_DB=gauth \
-p 5432:5432 \
postgres:17-alpine
```
#### 2. Redis'i Başlatın
```bash
# Docker ile
docker run -d \
--name gauth_redis \
-p 6379:6379 \
redis:7-alpine
```
#### 4. .env Dosyasını Yapılandırın
```bash
cp .env.example .env
# .env dosyasını düzenleyin
```
Örnek .env:
```env
PORT=8080
DB_URL="host=localhost user=postgres password=yourpassword dbname=gauth port=5432 sslmode=disable TimeZone=Europe/Istanbul"
REDIS_URL=redis://localhost:6379/0
JWT_SECRET=your_super_secret_key
```
#### 5. Uygulamayı Çalıştırın
```bash
# Geliştirme modu
go run main.go
# Veya derleyip çalıştırın
go build -o main .
./main
```
## 🔧 Yapılandırma Detayları
### PostgreSQL Bağlantısı
Uygulamanız PostgreSQL veritabanına bağlanacak ve otomatik olarak:
- Tabloları oluşturacak (migration)
- Seed data ekleyecek (roles, permissions)
- Email doğrulama sütununu güncelleyecek
### Redis Cache
Redis aşağıdaki amaçlarla kullanılır:
1. **Session Yönetimi**: Token-based session storage
2. **Rate Limiting**: API çağrılarını sınırlandırma
3. **Cache**: Kullanıcı verileri ve sık erişilen datalar
4. **Token Blacklist**: Logout işlemlerinde token iptal
5. **Email Verification**: Email doğrulama token'ları
6. **Password Reset**: Şifre sıfırlama token'ları
### CORS Yapılandırması
Varsayılan olarak `http://localhost:3000` origin'ine izin verilir. Değiştirmek için `main.go` dosyasını düzenleyin:
```go
AllowOrigins: []string{"http://localhost:3000", "https://yourdomain.com"},
```
## 🧪 Test Etme
### 1. Sağlık Kontrolü
```bash
curl http://localhost:8080/
```
### 2. Swagger UI
Tarayıcınızda: `http://localhost:8080/docs/index.html`
### 3. Kullanıcı Kaydı
```bash
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "SecurePass123!",
"user_name": "testuser"
}'
```
### 4. Giriş
```bash
curl -X POST http://localhost:8080/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "SecurePass123!"
}'
```
### 5. Redis Bağlantı Kontrolü
```bash
# Redis CLI ile
docker exec -it gauth_redis redis-cli
# Redis içinde
> PING
PONG
> KEYS *
(Redis'teki tüm key'leri gösterir)
> GET user:UUID_HERE
(Kullanıcı cache verisi)
```
### 6. PostgreSQL Bağlantı Kontrolü
```bash
# PostgreSQL CLI ile
docker exec -it gauth_postgres psql -U postgres -d gauth
# PostgreSQL içinde
\dt -- Tabloları listele
\d users -- Users tablosu yapısını göster
SELECT * FROM roles; -- Rolleri listele
```
## 📊 Rate Limiting Yapılandırması
Varsayılan limitler:
- **Login**: 5 deneme / dakika
- **Register**: 3 deneme / 5 dakika
- **Genel API**: 100 istek / dakika
Değiştirmek için `api/middlewares/rate_limit_middleware.go` dosyasını düzenleyin.
## 🔐 OAuth Yapılandırması
### Google OAuth
1. [Google Cloud Console](https://console.cloud.google.com/) → API & Services → Credentials
2. OAuth 2.0 Client ID oluşturun
3. Authorized redirect URIs: `http://localhost:8080/v1/auth/google/callback`
4. Client ID ve Secret'ı `.env` dosyasına ekleyin
### GitHub OAuth
1. [GitHub Developer Settings](https://github.com/settings/developers) → OAuth Apps → New
2. Authorization callback URL: `http://localhost:8080/v1/auth/github/callback`
3. Client ID ve Secret'ı `.env` dosyasına ekleyin
## 🐛 Sorun Giderme
### Redis bağlanamıyor
```bash
# Redis durumunu kontrol et
docker ps | grep redis
# Redis loglarını kontrol et
docker logs gauth_redis
# Redis'i yeniden başlat
docker restart gauth_redis
```
### PostgreSQL bağlanamıyor
```bash
# PostgreSQL durumunu kontrol et
docker ps | grep postgres
# PostgreSQL loglarını kontrol et
docker logs gauth_postgres
# Bağlantıyı test et
docker exec -it gauth_postgres pg_isready -U postgres
```
### CORS hatası alıyorum
`main.go` dosyasında `AllowOrigins` değerini kontrol edin ve frontend URL'inizi ekleyin.
### Rate limit çok düşük
`api/middlewares/rate_limit_middleware.go` dosyasında limit değerlerini artırın.
## 📝 Notlar
- Üretim ortamında `JWT_SECRET` değerini güçlü bir değerle değiştirin
- Redis şifre koruması için production'da Redis AUTH kullanın
- PostgreSQL için SSL bağlantısı kullanın (sslmode=require)
- Log seviyelerini production'da ayarlayın
- CORS origin'lerini production domain'lerinizle güncelleyin
## 🔄 Güncellemeler
Swagger dokümantasyonunu güncellemek için:
```bash
swag init -g main.go
```
Migration eklemek için:
`internal/database/db.go` dosyasındaki `Migrate()` fonksiyonunu güncelleyin.
## 📚 Daha Fazla Bilgi
- [Gin Web Framework](https://gin-gonic.com/)
- [GORM ORM](https://gorm.io/)
- [Redis Go Client](https://redis.uptrace.dev/)
- [JWT Go](https://github.com/golang-jwt/jwt)

9
docs/api_backend.txt Normal file
View File

@@ -0,0 +1,9 @@
/ --> gauth-central/api/routes.SetupRoutes.func1 (3 handlers)
[GIN-debug] GET /docs/*any --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (3 handlers)
[GIN-debug] POST /v1/auth/register --> gauth-central/api/handlers.(*AuthHandler).Register-fm (3 handlers)
[GIN-debug] POST /v1/auth/login --> gauth-central/api/handlers.(*AuthHandler).Login-fm (3 handlers)
[GIN-debug] GET /v1/auth/:provider --> gauth-central/api/handlers.(*AuthHandler).BeginAuth-fm (3 handlers)
[GIN-debug] GET /v1/auth/:provider/callback --> gauth-central/api/handlers.(*AuthHandler).Callback-fm (3 handlers)
[GIN-debug] POST /v1/auth/refresh --> gauth-central/api/handlers.(*AuthHandler).Refresh-fm (3 handlers)
[GIN-debug] GET /v1/auth/me --> gauth-central/api/handlers.(*AuthHandler).Me-fm (4 handlers)
[GIN-debug] GET /v1/auth/validate