jwt

package
v0.0.0-...-0871eb3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package jwt is authentication by JWT

Index

Constants

View Source
const (
	//HMAC is for signature
	HMAC uint8 = 1
	//RSA is for signature
	RSA uint8 = 2
)

Variables

This section is empty.

Functions

func CreateBasicToken

func CreateBasicToken(t int64, clientID, userName string) (string, error)

CreateBasicToken is to encode Header,Payload,Signature by Base64 and concatenate these by dot. This is for basic claim

func CreateToken

func CreateToken(t int64, clientID, userName, option string) (string, error)

CreateToken is to encode Header,Payload,Signature by Base64 and concatenate these by dot. This is for user defined claim

func InitAudience

func InitAudience(str string)

InitAudience is to set audience

func InitEncrypted

func InitEncrypted(mode uint8)

InitEncrypted is to set encrypted

func InitKeys

func InitKeys(priKey, pubKey string) (err error)

InitKeys is for RSA and load rsa files

func InitSecretKey

func InitSecretKey(str string)

InitSecretKey is for HMAC

func JudgeJWT

func JudgeJWT(tokenString string) error

JudgeJWT is to check token (it may be too strict to check)

func JudgeJWTWithClaim

func JudgeJWTWithClaim(tokenString, clientID, userName string) error

JudgeJWTWithClaim is to check token by clientID and userName It may be too strict to check

func JudgeJWTWithCustomClaim

func JudgeJWTWithCustomClaim(tokenString, clientID, userName, option string) error

JudgeJWTWithCustomClaim is to check token by clientId and userName and option It may be too strict to check

Types

type CustomClaims

type CustomClaims struct {
	Option string `json:"option"`
	jwt.StandardClaims
}

CustomClaims is structure of json for jwt claim

Jump to

Keyboard shortcuts

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