jwt

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 5 Imported by: 0

README

jwt

import "github.com/euforic/pkg-go/jwt"

Index

type JWT

JWT

type JWT struct {
    // contains filtered or unexported fields
}
func New
func New(privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) *JWT

New creates a new instance of JWT util

func (JWT) CreatAndSign
func (j JWT) CreatAndSign(ttl time.Duration, claims jwt.MapClaims) (string, error)

CreateAndSign a new jwt token

func (JWT) Create
func (j JWT) Create(ttl time.Duration, claims jwt.MapClaims) (*Token, error)

Create generates a new jwt token string

func (JWT) Parse
func (j JWT) Parse(token string, validate bool) (*Token, error)

Parse takes in a jwt token string parses it, validates it and return a *Token

func (JWT) Sign
func (j JWT) Sign(token *Token) (string, error)

Create generates a new jwt token string

type Token

type Token struct {
    *jwt.Token
    // contains filtered or unexported fields
}
func NewToken
func NewToken(t *jwt.Token) *Token

NewToken creates a new instance of Token from a *jwt.Token

func (Token) Claims
func (t Token) Claims() (value jwt.MapClaims, exists bool)
func (Token) Get
func (t Token) Get(key string) (value interface{}, exists bool)
func (Token) GetBool
func (t Token) GetBool(key string) (b bool)

GetBool returns the value associated with the key as a boolean.

func (Token) GetDuration
func (t Token) GetDuration(key string) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (Token) GetFloat64
func (t Token) GetFloat64(key string) (f64 float64)

GetFloat64 returns the value associated with the key as a float64.

func (Token) GetInt
func (t Token) GetInt(key string) (i int)

GetInt returns the value associated with the key as an integer.

func (Token) GetInt64
func (t Token) GetInt64(key string) (i64 int64)

GetInt64 returns the value associated with the key as an integer.

func (Token) GetSlice
func (t Token) GetSlice(key string) []interface{}

GetSlice returns the value associated with the key as a slice of interface{}.

func (Token) GetString
func (t Token) GetString(key string) (s string)

GetString returns the value associated with the key as a string.

func (Token) GetStringSlice
func (t Token) GetStringSlice(key string) (ss []string)

GetStringSlice returns the value associated with the key as a slice of strings.

func (Token) GetTime
func (t Token) GetTime(key string) (tm time.Time)

GetTime returns the value associated with the key as time.

func (Token) GetUint
func (t Token) GetUint(key string) (ui uint)

GetUint returns the value associated with the key as an unsigned integer.

func (Token) GetUint64
func (t Token) GetUint64(key string) (ui64 uint64)

GetUint64 returns the value associated with the key as an unsigned integer.

func (Token) ParseError
func (t Token) ParseError() error

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

JWT

func New

func New(privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey) *JWT

New creates a new instance of JWT util

func (JWT) CreatAndSign

func (j JWT) CreatAndSign(ttl time.Duration, claims jwt.MapClaims) (string, error)

CreateAndSign a new jwt token

func (JWT) Create

func (j JWT) Create(ttl time.Duration, claims jwt.MapClaims) (*Token, error)

Create generates a new jwt token string

func (JWT) Parse

func (j JWT) Parse(token string, validate bool) (*Token, error)

Parse takes in a jwt token string parses it, validates it and return a *Token

func (JWT) Sign

func (j JWT) Sign(token *Token) (string, error)

Create generates a new jwt token string

type Token

type Token struct {
	*jwt.Token
	// contains filtered or unexported fields
}

func NewToken

func NewToken(t *jwt.Token) *Token

NewToken creates a new instance of Token from a *jwt.Token

func (Token) Claims

func (t Token) Claims() (value jwt.MapClaims, exists bool)

func (Token) Get

func (t Token) Get(key string) (value interface{}, exists bool)

func (Token) GetBool

func (t Token) GetBool(key string) (b bool)

GetBool returns the value associated with the key as a boolean.

func (Token) GetDuration

func (t Token) GetDuration(key string) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (Token) GetFloat64

func (t Token) GetFloat64(key string) (f64 float64)

GetFloat64 returns the value associated with the key as a float64.

func (Token) GetInt

func (t Token) GetInt(key string) (i int)

GetInt returns the value associated with the key as an integer.

func (Token) GetInt64

func (t Token) GetInt64(key string) (i64 int64)

GetInt64 returns the value associated with the key as an integer.

func (Token) GetSlice

func (t Token) GetSlice(key string) []interface{}

GetSlice returns the value associated with the key as a slice of interface{}.

func (Token) GetString

func (t Token) GetString(key string) (s string)

GetString returns the value associated with the key as a string.

func (Token) GetStringSlice

func (t Token) GetStringSlice(key string) (ss []string)

GetStringSlice returns the value associated with the key as a slice of strings.

func (Token) GetTime

func (t Token) GetTime(key string) (tm time.Time)

GetTime returns the value associated with the key as time.

func (Token) GetUint

func (t Token) GetUint(key string) (ui uint)

GetUint returns the value associated with the key as an unsigned integer.

func (Token) GetUint64

func (t Token) GetUint64(key string) (ui64 uint64)

GetUint64 returns the value associated with the key as an unsigned integer.

func (Token) ParseError

func (t Token) ParseError() error

Directories

Path Synopsis
middleware

Jump to

Keyboard shortcuts

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