Skip to content

wpcodevo/golang-gorm-postgres

 
 

Repository files navigation

API with Golang + GORM + PostgreSQL: Access & Refresh Tokens

This article will teach you how to secure a Golang application with access and refresh tokens using GORM, Postgres, Docker, and Docker-compose. Also, you will learn how to use the RS256 algorithm with private and public keys to sign the tokens.

API with Golang + GORM + PostgreSQL: Access & Refresh Tokens

Topics Covered

  • Golang, Gin & GORM JWT Authentication Overview
  • JWT Authentication Example with Golang and GORM
  • Generate the Private and Public Keys
  • Load and Validate the Environment Variables
  • Create the Database Models with GORM
  • Run the Database Migration with GORM
  • Hash and Verify the Passwords with Bcrypt
  • Sign and Verify the RS256 JSON Web Tokens
    • Function to Generate the Tokens
    • Function to Verify the Tokens
  • Create the Authentication Route Controllers
    • Register User Controller
    • Login User Controller
    • Refresh Access Token Controller
    • Logout Controller
  • Create a Middleware Guard
  • Create a User Controller
    • Authentication Routes
    • User Routes
  • Add the Routes to the Gin Middleware Stack

Read the entire article here: https://codevoweb.com/golang-gorm-postgresql-user-registration-with-refresh-tokens

Articles in this series:

1. How to Setup Golang GORM RESTful API Project with Postgres

How to Setup Golang GORM RESTful API Project with Postgres

2. API with Golang + GORM + PostgreSQL: Access & Refresh Tokens

API with Golang + GORM + PostgreSQL: Access & Refresh Tokens

3. Golang and GORM - User Registration and Email Verification

Golang and GORM - User Registration and Email Verification

4. Forgot/Reset Passwords in Golang with SMTP HTML Email

Forgot/Reset Passwords in Golang with SMTP HTML Email

5. Build a RESTful CRUD API with Golang

Build a RESTful CRUD API with Golang

About

In this comprehensive guide, you will learn how to secure a Golang RESTful API with JSON Web Tokens and Email verification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages