gwt

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gwt implements an api token manager with rsa crypto

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(secret string, encoding string)

Config sets the secret and encoding of the default GWT

func IsExpired added in v0.5.5

func IsExpired(err error) bool

IsExpired returns a boolean indicating whether the error is known to report that a gwt token is expired.

func ParseToken

func ParseToken(tokenString string, v interface{}) (err error)

ParseToken parses a token

func ParseTokenBy added in v0.5.5

func ParseTokenBy(issuer string, tokenString string, v interface{}) (err error)

ParseTokenBy parses a token with issuer

func SignToken

func SignToken(payload interface{}, expires time.Duration) (token string, err error)

SignToken creates a token

func SignTokenBy added in v0.5.5

func SignTokenBy(issuer string, payload interface{}, expires time.Duration) (token string, err error)

SignTokenBy creates a token with issuer

Types

type Channel

type Channel struct {
	Payload   []byte
	ExpiresAt int64
	Issuer    string
}

Channel is a payload container includes expires and issuer for GWT

type GWT

type GWT struct {
	Secret   string
	Encoding string
}

GWT is an api token manager with rsa crypto

func (*GWT) ParseToken

func (gwt *GWT) ParseToken(tokenString string, v interface{}) (err error)

ParseToken parses a token

func (*GWT) ParseTokenBy added in v0.5.5

func (gwt *GWT) ParseTokenBy(issuer string, tokenString string, v interface{}) (err error)

ParseTokenBy parses a token with issuer

func (*GWT) SignToken

func (gwt *GWT) SignToken(payload interface{}, expires time.Duration) (token string, err error)

SignToken creates a token

func (*GWT) SignTokenBy added in v0.5.5

func (gwt *GWT) SignTokenBy(issuer string, payload interface{}, expires time.Duration) (token string, err error)

SignTokenBy creates a token with issuer

Jump to

Keyboard shortcuts

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