auth

package module
v0.0.0-...-96b5457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

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

Documentation

Overview

Package auth provides the easy function to validate the JWT, simple plug and play. Its easy function to protect your api JWT See https://jwt.io

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTAuthMiddleware

func JWTAuthMiddleware(encoded bool, secret string) gin.HandlerFunc

JWTAuthMiddleware middleware function implementation

func RespondWithError

func RespondWithError(code int, message string, c *gin.Context)

RespondWithError function handler error

Types

type APIError

type APIError struct {
	Code    int
	Message string
}

APIError struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL