This is the simple Golang project that covers basic API functionalities like authentication, send verification code, middleware etc.
- Golang, Gin & GORM JWT Authentication
- 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
- Forgot and reset password
- Role based route using middlewares
cp app.env.example app.env
- Generate private and public keys from HERE
- Copy the key andnavigate HERE to convert it into base64 string
- Assign the values to respective keys in app.env file
go run migrate/migrate.go
go run cmd/*