command
module
Version:
v0.0.0-...-073e33b
Opens a new window with list of versions in this module.
Published: Feb 27, 2024
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
JWT Authentication in Golang
This project demonstrates how to implement JWT (JSON Web Token) authentication in a Golang web application using Gin framework.
Features
- User signup: Users can register by providing a username, email, and password.
- User login: Registered users can log in using their email and password.
- JWT Authentication: JWT is used to generate and authenticate user tokens for secure access to protected routes.
Prerequisites
- Go (v1.16 or later)
- PostgreSQL (v9.5 or later)
Getting Started
-
Clone the repository:
git clone https://github.com/CABON-TECH/jwt-auth-in-golang.git
-
Navigate to the project directory:
cd jwt-auth-in-golang
-
Install dependencies:
go mod tidy
-
Set up the PostgreSQL database:
- Create a PostgreSQL database named
jwt_db
.
- Update the database connection details in
initializers/connectDB.go
file.
-
Set environment variables:
Create a .env
file in the root directory and define the following environment variables:
SECRET=your-secret-key
-
Run the application:
go run main.go
-
Access the application in your web browser at http://localhost:8080
.
API Endpoints
User Signup
User Login
License
This project is licensed under the MIT License - see the LICENSE file for details.
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.