jwts

package
v0.0.0-...-db3cac9 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomClaims

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

CustomClaims is jwt claim

type JWTAlgo

type JWTAlgo string

JWTAlgo is JWT encryption algorism

const (
	// AlgoHMAC is HMAC signing algorithm
	AlgoHMAC JWTAlgo = "hmac"
	// AlgoRSA is RSA signing algorithm
	AlgoRSA JWTAlgo = "rsa"
)

type JWTer

type JWTer interface {
	CreateBasicToken(t int64, clientID, userName string) (string, error)
	CreateCustomToken(t int64, clientID, userName, option string) (string, error)
	ValidateToken(tokenString string) error
	ValidateTokenWithClaim(tokenString, clientID, userName string) error
	ValidateTokenWithCustomClaim(tokenString, clientID, userName, option string) error
}

JWTer interface

func NewJWT

func NewJWT(audience string, sigAlgoer SigAlgoer) JWTer

NewJWT returns JWTer interface

type SigAlgoer

type SigAlgoer interface {
	GetMethod() jwt.SigningMethod
	SignedString(token *jwt.Token) (string, error)
	ValidateMethod(token *jwt.Token) bool
	GetKey() interface{}
}

SigAlgoer interface

func NewHMAC

func NewHMAC(secret string) SigAlgoer

NewHMAC returns SigAlgoer

func NewRSA

func NewRSA(privKey, pubKey string) (SigAlgoer, error)

NewRSA returns SigAlgoer interface and error

type SimpleJWTer

type SimpleJWTer interface {
	GenerateToken(userID int) (string, error)
}

func NewSimpleJWT

func NewSimpleJWT(key string) SimpleJWTer

Jump to

Keyboard shortcuts

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