Go-User-Authentication

command module
v0.0.0-...-fdc88a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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": "user@mail.com",
    "password": "Secret"
}'
Login User

Endpoint: POST: "/login"

curl --location 'http://localhost:9000/login' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "user@mail.com",
    "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'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL