/gin-jwt-middleware

A simple middleware for gin handle the jwt token

Primary LanguageGoApache License 2.0Apache-2.0

gin-jwt-middleware

Build Status codecov Go Report Card

What is JWT?

JSON Web Token (JWT) more information: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html

How to use this?

Install package

$ go get github.com/jayhuang75/gin-jwt-middleware

In your gin application main.go, import the package

import (
    "github.com/jayhuang75/gin-jwt-middleware"
)

Use the middleware

app := gin.Default()

app.Use(auth.JWTAuthMiddleware(encoded, YOUR_SECRET)
  • encoded is a boolen: if your JWT secret is encoded
  • YOUR_SECRET: Your JWT secret, here you can use the env variable