jwt

package
v0.0.0-...-fb0f190 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: AGPL-3.0 Imports: 12 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 HashBorrower

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

HashBorrower keeps track of borrowed hashers and allows to return them all.

func (*HashBorrower) Borrow

func (h *HashBorrower) Borrow() hash.Hash

Borrow a single hasher.

func (*HashBorrower) ReturnAll

func (h *HashBorrower) ReturnAll()

ReturnAll will return all borrowed hashes.

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) GetAccessKey

func (c *MapClaims) GetAccessKey() string

GetAccessKey will return the access key. If nil an empty string will be returned.

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/golang-jwt/jwt#Claims compatible claims interface, additionally validates "accessKey" fields.

type SigningMethodHMAC

type SigningMethodHMAC struct {
	Name       string
	Hash       crypto.Hash
	HasherPool sync.Pool
}

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(token []byte, 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(token []byte, 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.

func (*SigningMethodHMAC) HashBorrower

func (s *SigningMethodHMAC) HashBorrower() HashBorrower

HashBorrower allows borrowing hashes and will keep track of them.

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) UnmarshalJSON

func (c *StandardClaims) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON provides custom JSON unmarshal. This is mainly implemented for speed.

func (*StandardClaims) Valid

func (c *StandardClaims) Valid() error

Valid - implements https://godoc.org/github.com/golang-jwt/jwt#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