8000 GitHub - Pradumn27/go-jwt
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pradumn27/go-jwt

Repository files navigation

JWT Authentication

JWT Aunthentication and Authorization using golang

Technologies Used

  1. Go (Golang) - Backend language
  2. Fiber - Web framework for Go
  3. MongoDB - NoSQL database for storing user data
  4. JWT (JSON Web Tokens) - Token-based authentication
  5. Docker - Containerization for running MongoDB and API

Running the Project

Essentials:

  1. Make sure you have docker installed on your system
  2. Clone the repository and open the project

Run the below command

docker-compose up --build

API Endpoints and Usage

  1. Sign Up: Registers a new user with an email and password.
curl -X POST http://localhost:3000/auth/signup \
     -H "Content-Type: application/json" \
     -d '{
           "email": "user@example.com",
           "password": "securepassword"
         }'
  1. Sign In: Authenticates a user and returns a JWT token.
curl -X POST http://localhost:3000/auth/signin \
     -H "Content-Type: application/json" \
     -d '{
           "email": "user@example.com",
           "password": "securepassword"
         }'
  1. Refresh Token: Generates a new token using the old one.
curl -X GET http://localhost:3000/auth/refresh \
     -H "Authorization: Bearer ${Token}"
  1. Revoke Token: Invalidates the provided JWT token.
curl -X POST http://localhost:3000/auth/revoke \
     -H "Authorization: Bearer ${Token}"
  1. Get User Details: Fetches the details of the authenticated user.
curl -X GET http://localhost:3000/user/details \
     -H "Content-Type: application/json"  \
     -H "Authorization: Bearer ${Token}"

Note: In the above-mentioned curl requests replace your obtained token with ${Token}

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0