Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/raihan2bd/jwt-authentication-golang

A Go-based web application using PostgreSQL for data storage, GORM for database interaction, and Gin for routing. It offers user registration, login, and authentication with JWT tokens for secure access to protected routes.
https://github.com/raihan2bd/jwt-authentication-golang

gin go golang gorm jwt posgresql

Last synced: 28 days ago
JSON representation

A Go-based web application using PostgreSQL for data storage, GORM for database interaction, and Gin for routing. It offers user registration, login, and authentication with JWT tokens for secure access to protected routes.

Awesome Lists containing this project

README

        


Jwt Authentication with Golang

# 📗 Table of Contents

- [📗 Table of Contents](#-table-of-contents)
- [ jwt-authentication-golang ](#-about-project-)
- [🛠 Built With ](#-built-with-)
- [Tech Stack ](#tech-stack-)
- [Key Features ](#key-features-)
- [💻 Getting Started ](#-getting-started-)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Install](#install)
- [Usage](#usage)
- [Build](#build)
- [👥 Author ](#-author-)
- [🔭 Future Features ](#-future-features-)
- [🤝 Contributing ](#-contributing-)
- [⭐️ Show your support ](#️-show-your-support-)
- [🙏 Acknowledgments ](#-acknowledgments-)
- [📝 License ](#-license-)

# Jwt Authentication with Golang and Gorm
A Go-based web application using PostgreSQL for data storage, GORM for database interaction, and Gin for routing. It offers user registration, login, and authentication with JWT tokens for secure access to protected routes.

## 🛠 Built With
### Tech Stack

Back End


  • Golang

  • PostgreSQL

  • Gin

  • Gorm

### Key Features

- Users can login
- User can signup
- User can check if they are authenticated or not

(back to top)

## 💻 Getting Started

To get a local copy up and running, follow these steps.

### Prerequisites

In order to run this project you need:
- Then Make sure you have installed [Go (golang)](https://go.dev/dl/) version 1.20.4 or the latest stable version.
- Then make sure you have installed [PostgreSQL](https://www.postgresql.org/) on your local machine if you want to use this project locally.
- Then Create a database called `jwt-go-pos`

### Setup

- Clone this repository to your desired folder:

```sh
cd your-folder
https://github.com/raihan2bd/jwt-authentication-golang.git
```

- Before running the project please make sure you create a `.env` file to your project root directory and add `DATABASE_URI`, and `JWT_SECRET_KEY` environment variables to the file. For example:
```
DATABASE_URI="host=localhost port=5432 dbname=jwt-go-pos user=postgres password=your password sslmode=disable"
JWT_SECRET="your jwt secret key"
```

### Install

Install this project with:

- Install the required gems with:

```sh
go mod tidy
```

### Usage

- To run the development server, execute the following command:

```sh
go run .
```

### Build

- To build the project for production-ready run the following command:

```sh
go build -o myapp
```

- To run the build file

```sh
./myapp
```

## 👥 Author

👤 **Abu Raihan**

- GitHub: [@raihan2bd](https://github.com/raihan2bd)
- Twitter: [@raihan2bd](https://twitter.com/raihan2bd)
- LinkedIn: [raihan2bd](https://linkedin.com/in/raihan2bd)

(back to top)

## 🔭 Future Features

- [ ] **I will add more end-points to this project**

(back to top)

## 🤝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the [issues page](https://github.com/raihan2bd/jwt-authentication-golang/issues).

(back to top)

## ⭐️ Show your support

If you like this project, please leave a ⭐️

(back to top)

## 🙏 Acknowledgments

I would like to thank [Trevor Sawler](https://www.gocode.ca/) Who helped me a lot to learn Golang.

(back to top)

## 📝 License

This project is [MIT](./LICENSE) licensed.

(back to top)