vaibhavsingh9 / go-fiber-jwt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JWT

Reference taken from BLOG

Run docker image

docker-compose up -d

To Run:

go get ./
go run main.go
  1. Sign up (creation of user) using email and password:

    http://127.0.0.1:8000/api/auth/register/ 
    {
      "name":"First",
      "email":"first@gmail.com",
      "password":"123456789",
      "passwordconfirm":"123456789"
    }
    
  2. Sign in
    a. Authentication of user credentials
    b. A token is returned as response preferably JWT

    http://127.0.0.1:8000/api/auth/login/
    
    {
        "name":"First",
        "email":"first@gmail.com",
    }
  1. Authorization of token
    a. Mechanism of sending token along with a request from client to service
    -> Tokens sent as cookies
    b. Should check for expiry
    -> Validate function in token.go
    c. Error handling (proper error codes in each failure scenario)

  2. Revocation of token
    a. Mechanism of revoking a token from backend
    -> Implemented in logout route, through Redis DEL function, the token will be deleted

  3. Mechanism to refresh a token
    a. Client should be able to renew the token before it expires
    -> Implemented

Used frameworks and libraries:

  1. Fiber
  2. Gorm
  3. Viper
  4. JWT
  5. Validators
  6. Go-Redis
  7. Postgres

About


Languages

Language:Go 100.0%