jwt

package module
v0.0.0-...-d89f8f7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2016 License: MIT Imports: 12 Imported by: 0

README

go-jwt

Base on dgrijalva/jwt-go

JSON Web Tokens

Overview

  • Default support Hmac512 and RSA
  • Tool to generate keys, include Hmac512, RSA
  • Dynamic loading the keys, easy way to manage
  • Simplified common functions, deploy into any project quickly

Installation

go get -u github.com/WindomZ/go-jwt

TODO

  • Usage
  • Struct for header setting

LICENSE

MIT(http://opensource.org/licenses/mit-license.php)

Documentation

Index

Constants

View Source
const (
	DEFAULT_KID_HMAC string = "hmac_default"
	DEFAULT_KID_RSA         = "rsa_default"
)
View Source
const (
	KID = "kid"
	ARG = "arg"
	EXP = "exp"
)
View Source
const (
	TagHmac string = StringHmac
	TagRSA         = StringRSA
)

Variables

View Source
var (
	ErrInit error = errors.New("jwt: Fail to initialize jwt")
	ErrNil        = errors.New("jwt: This is nil")
)
View Source
var (
	ErrToken          error = errors.New("jwt: That's not even a token")
	ErrTokenExpired         = errors.New("jwt: Token is expired")
	ErrTokenNotActive       = errors.New("jwt: Token is not active yet")
	ErrRequest              = errors.New("jwt: Request error")
	ErrResponse             = errors.New("jwt: Response error")
)
View Source
var (
	ErrJwtHandler  error = errors.New("jwt: That's not even a jwt handler")
	ErrJwtHandlers       = errors.New("jwt: These are not jwt handler")
	ErrExistKID          = errors.New("jwt: There is no this KID")
)
View Source
var (
	ErrHandleTokenFunc = func(err error) error {
		return errors.New(fmt.Sprintf("jwt: Couldn't handle this token with error(%v)", err.Error()))
	}
)

Functions

func IsTimeOutErr

func IsTimeOutErr(err error) bool

func Parse

func Parse(token string) (interface{}, error)

Parse, validate, and return a token.

func ParseRequest

func ParseRequest(req *http.Request) (interface{}, error)

Parse http request, validate, and return a token.

func ParseResponse

func ParseResponse(resp *http.Response) (interface{}, error)

Parse http response, validate, and return a token.

func SetHTTPHeaderKey

func SetHTTPHeaderKey(key string)

set key and prefix value in http.Request header entries

func Sign

func Sign(kid string, arg interface{}, minutes int) (string, error)

Generate the signing string.

func SignRequest

func SignRequest(req *http.Request, kid string, arg interface{}, minutes int) error

Generate the signing string, and set into http request

func SignResponse

func SignResponse(rw http.ResponseWriter, kid string, arg interface{}, minutes int) error

Generate the signing string, and set into http response writer

Types

type Config

type Config struct {
	KeyFileDir string
}

func NewConfig

func NewConfig(fileDir string) *Config

Create a new configuration object fileDir is the directory of key file(s)

func (*Config) Effect

func (s *Config) Effect() error

Configuration to take effect

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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