Categorygithub.com/Garg-Shashwat/Go-User-Authentication
modulepackage
0.0.0-20241203094853-fdc88a6d816a
Repository: https://github.com/garg-shashwat/go-user-authentication.git
Documentation: pkg.go.dev

# README

User Auth Service

This project provides an authentication service with JWT token-based authentication using Go, PostgreSQL, and Docker. It includes endpoints for user signup, signin, token generation, verification and renewal.

Table of Contents

Tech Stack

  • Go - Programming language used for the backend logic.
  • PostgreSQL - Relational database for storing user and token data.
  • JWT (JSON Web Tokens) - Used for secure token-based authentication.
  • Docker & Docker Compose - Containerization and orchestration of services.
  • GORM - ORM library for interacting with the PostgreSQL database.

Installation

Prerequisites

  • Docker and Docker Compose
  • Go (v1.23+)

Clone the Repository

git clone https://github.com/Garg-Shashwat/Go-User-Authentication.git

Installation

go mod tidy

Configuration

.env.main file included

Running the Application

docker-compose up

docker-compose down

API Endpoints

Ping server

Endpoint: GET: "/ping"

curl --location 'http://localhost:9000/ping'

Register User

Endpoint: POST: "/register"

curl --location 'http://localhost:9000/register' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "[email protected]",
    "password": "Secret"
}'

Login User

Endpoint: POST: "/login"

curl --location 'http://localhost:9000/login' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "[email protected]",
    "password": "Secret"
}'

Renew Token

Endpoint: GET: "/refresh_token"

curl --location 'http://localhost:9000/refresh_token' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzI0NzUxOTYsImlhdCI6MTczMjQ2Nzk5Niwic3ViIjoyfQ.l9zXzEt-oEpqOpx5x2Ndxra-cnNA3uj6KW8LDzdkiK8'

Logout (Revoke Token)

Endpoint: GET: "/logout"

curl --location 'http://localhost:9000/logout' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzI0NzUxOTYsImlhdCI6MTczMjQ2Nzk5Niwic3ViIjoyfQ.l9zXzEt-oEpqOpx5x2Ndxra-cnNA3uj6KW8LDzdkiK8'

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author