func ValidateAuthorization() gin.HandlerFunc {
	return func(c *gin.Context) {
		const verifyRequired = true
		var err error
		var userProperty interface{}
		var claims jwt.MapClaims
		if err = jwtMiddleware.CheckJWT(c.Writer, c.Request); err != nil {
			c.Abort()
			return
		}
		userProperty = c.Request.Context().Value(authUserProperty)
		claims = userProperty.(*jwt.Token).Claims.(jwt.MapClaims)
		if !claims.VerifyAudience(globals.Conf.App.JwtAudience, verifyRequired) ||
			!claims.VerifyIssuer(globals.Conf.App.JwtIssuer, verifyRequired) {
			c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
				"status": "fail",
				"data": gin.H{
					"req.Cookies.id_token": "aud or issuer claim is invalid",
				},
			})
			return
		}
		var newRequest *http.Request
		newRequest = c.Request.WithContext(context.WithValue(c.Request.Context(), globals.AuthUserIDProperty, claims["user_id"]))
		*c.Request = *newRequest
	}
}
ValidateAuthorization checks the jwt token in the Authorization header is valid or not
package middlewares
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"github.com/twreporter/go-api/globals"
	"github.com/twreporter/go-api/utils"
	"github.com/auth0/go-jwt-middleware"
	"github.com/dgrijalva/jwt-go"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)
const authUserProperty = "app-auth-jwt"
var jwtMiddleware = jwtmiddleware.New(jwtmiddleware.Options{
	ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
		return []byte(globals.Conf.App.JwtSecret), nil
	},
	UserProperty:  authUserProperty,
	SigningMethod: jwt.SigningMethodHS256,
	ErrorHandler: func(w http.ResponseWriter, r *http.Request, err string) {
		var res = map[string]interface{}{
			"status": "fail",
			"data": map[string]interface{}{
				"req.Headers.Authorization": err,
			},
		}
		var resByte, _ = json.Marshal(res)
		http.Error(w, string(resByte), http.StatusUnauthorized)
	},
})