Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amit9887/jwt-authentication-gin-golang
This repository contains a basic JWT authentication system built with Golang. It utilizes the Gin framework for HTTP handling, Gorm for ORM, and MySQL as the database. The project demonstrates secure user authentication using JSON Web Tokens (JWT).
https://github.com/amit9887/jwt-authentication-gin-golang
authentication gin golang gorm jwt mysql
Last synced: about 1 month ago
JSON representation
This repository contains a basic JWT authentication system built with Golang. It utilizes the Gin framework for HTTP handling, Gorm for ORM, and MySQL as the database. The project demonstrates secure user authentication using JSON Web Tokens (JWT).
- Host: GitHub
- URL: https://github.com/amit9887/jwt-authentication-gin-golang
- Owner: Amit9887
- Created: 2024-08-04T12:54:03.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-05T09:12:28.000Z (3 months ago)
- Last Synced: 2024-10-15T17:21:42.710Z (about 1 month ago)
- Topics: authentication, gin, golang, gorm, jwt, mysql
- Language: Go
- Homepage:
- Size: 8.85 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Go JWT Authentication
Welcome to the Go JWT Authentication project! This repository contains a robust and secure JWT authentication system built with Golang. It leverages the power of Gin for the HTTP framework, Gorm for ORM, and MySQL as the database. Let's get you started!✨ Features
JWT Authentication: Secure authentication using JSON Web Tokens.
Gin Framework: Fast and easy-to-use HTTP web framework.
Gorm ORM: Powerful ORM library for Golang.
MySQL Database: Reliable and scalable database solution.
�� Prerequisites
Before you begin, ensure you have the following installed on your system:Golang
�� Installation
Follow these steps to set up the project on your local machine:Clone the repository:
git clone https://github.com/your-repo/go-jwt-authentication.git
cd go-jwt-authentication
Install the required packages:
go get -u gorm.io/gorm
go get -u gorm.io/driver/mysql
go get -u github.com/gin-gonic/gin
go get -u golang.org/x/crypto/bcrypt
go get -u github.com/golang-jwt/jwt/v5
go get github.com/lpernett/godotenv
go get github.com/githubnemo/CompileDaemon
��️ Configuration
Database Connection:Replace the database connection string in the .env file with your specific database configuration.
Secret Key:
You can also change the secret key for JWT in the .env file.
�� Build and Run
Build the project:go build -o go-jwt-authentication
Run the executable binary:
./go-jwt-authentication
�� Testing
Use Postman or Thunder Client to test the API endpoints. Remember to add the token only to the cookies. The API endpoints available for testing are:Signup:
POST http://localhost:9090/signup
Login:POST http://localhost:9090/login
Validate:
GET http://localhost:9090/validate
��️ Technology Stack
Golang: Programming language.
Gin: HTTP web framework.
Gorm: ORM library.
JWT: JSON Web Tokens for authentication.
MySQL: Database.