Documentation ¶
Index ¶
- func ParseWithClaims(tokenStr string, claims *MapClaims, fn func(*MapClaims) ([]byte, error)) error
- func ParseWithStandardClaims(tokenStr string, claims *StandardClaims, key []byte) error
- type HashBorrower
- type MapClaims
- func (c *MapClaims) GetAccessKey() string
- func (c *MapClaims) Lookup(key string) (value string, ok bool)
- func (c *MapClaims) Map() map[string]interface{}
- func (c *MapClaims) MarshalJSON() ([]byte, error)
- func (c *MapClaims) SetAccessKey(accessKey string)
- func (c *MapClaims) SetExpiry(t time.Time)
- func (c *MapClaims) Valid() error
- type SigningMethodHMAC
- type StandardClaims
- func (c *StandardClaims) SetAccessKey(accessKey string)
- func (c *StandardClaims) SetAudience(aud string)
- func (c *StandardClaims) SetExpiry(t time.Time)
- func (c *StandardClaims) SetIssuer(issuer string)
- func (c *StandardClaims) UnmarshalJSON(b []byte) (err error)
- func (c *StandardClaims) Valid() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseWithClaims ¶
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) ReturnAll ¶
func (h *HashBorrower) ReturnAll()
ReturnAll will return all borrowed hashes.
type MapClaims ¶
MapClaims - implements custom unmarshaller
func (*MapClaims) GetAccessKey ¶
GetAccessKey will return the access key. If nil an empty string will be returned.
func (*MapClaims) MarshalJSON ¶
MarshalJSON marshals the MapClaims struct
func (*MapClaims) SetAccessKey ¶
SetAccessKey sets access key as jwt subject and custom "accessKey" field.
func (*MapClaims) Valid ¶
Valid - implements https://godoc.org/github.com/golang-jwt/jwt#Claims compatible claims interface, additionally validates "accessKey" fields.
type SigningMethodHMAC ¶
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.