jwt

package
v0.0.0-...-082243b Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseWithClaims

func ParseWithClaims(tokenStr string, claims *MapClaims, fn func(*MapClaims) ([]byte, error)) error

ParseWithClaims - parse the token string, valid methods.

func ParseWithStandardClaims

func ParseWithStandardClaims(tokenStr string, claims *StandardClaims, key []byte) error

ParseWithStandardClaims - parse the token string, valid methods.

Types

type MapClaims

type MapClaims struct {
	AccessKey string `json:"accessKey,omitempty"`
	jwtgo.MapClaims
}

MapClaims - implements custom unmarshaller

func NewMapClaims

func NewMapClaims() *MapClaims

NewMapClaims - Initializes a new map claims

func (*MapClaims) Lookup

func (c *MapClaims) Lookup(key string) (value string, ok bool)

Lookup returns the value and if the key is found.

func (*MapClaims) Map

func (c *MapClaims) Map() map[string]interface{}

Map returns underlying low-level map claims.

func (*MapClaims) MarshalJSON

func (c *MapClaims) MarshalJSON() ([]byte, error)

MarshalJSON marshals the MapClaims struct

func (*MapClaims) SetAccessKey

func (c *MapClaims) SetAccessKey(accessKey string)

SetAccessKey sets access key as jwt subject and custom "accessKey" field.

func (*MapClaims) SetExpiry

func (c *MapClaims) SetExpiry(t time.Time)

SetExpiry sets expiry in unix epoch secs

func (*MapClaims) Valid

func (c *MapClaims) Valid() error

Valid - implements https://godoc.org/github.com/dgrijalva/jwt-go#Claims compatible claims interface, additionally validates "accessKey" fields.

type SigningMethodHMAC

type SigningMethodHMAC struct {
	Name string
	Hash crypto.Hash
}

SigningMethodHMAC - Implements the HMAC-SHA family of signing methods signing methods Expects key type of []byte for both signing and validation

var (
	SigningMethodHS256 *SigningMethodHMAC
	SigningMethodHS384 *SigningMethodHMAC
	SigningMethodHS512 *SigningMethodHMAC
)

Specific instances for HS256, HS384, HS512

func ParseUnverifiedMapClaims

func ParseUnverifiedMapClaims(tokenString string, claims *MapClaims, buf []byte) (*SigningMethodHMAC, error)

ParseUnverifiedMapClaims - WARNING: Don't use this method unless you know what you're doing

This method parses the token but doesn't validate the signature. It's only ever useful in cases where you know the signature is valid (because it has been checked previously in the stack) and you want to extract values from it.

func ParseUnverifiedStandardClaims

func ParseUnverifiedStandardClaims(tokenString string, claims *StandardClaims, buf []byte) (*SigningMethodHMAC, error)

ParseUnverifiedStandardClaims - WARNING: Don't use this method unless you know what you're doing

This method parses the token but doesn't validate the signature. It's only ever useful in cases where you know the signature is valid (because it has been checked previously in the stack) and you want to extract values from it.

type StandardClaims

type StandardClaims struct {
	AccessKey string `json:"accessKey,omitempty"`
	jwtgo.StandardClaims
}

StandardClaims are basically standard claims with "accessKey"

func NewStandardClaims

func NewStandardClaims() *StandardClaims

NewStandardClaims - initializes standard claims

func (*StandardClaims) SetAccessKey

func (c *StandardClaims) SetAccessKey(accessKey string)

SetAccessKey sets access key as jwt subject and custom "accessKey" field.

func (*StandardClaims) SetAudience

func (c *StandardClaims) SetAudience(aud string)

SetAudience sets audience for these claims

func (*StandardClaims) SetExpiry

func (c *StandardClaims) SetExpiry(t time.Time)

SetExpiry sets expiry in unix epoch secs

func (*StandardClaims) SetIssuer

func (c *StandardClaims) SetIssuer(issuer string)

SetIssuer sets issuer for these claims

func (*StandardClaims) Valid

func (c *StandardClaims) Valid() error

Valid - implements https://godoc.org/github.com/dgrijalva/jwt-go#Claims compatible claims interface, additionally validates "accessKey" fields.

Jump to

Keyboard shortcuts

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