Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoKeyID returned if the JWT lacks a kid value in the header. ErrNoKeyID = errors.New("missing key ID in header") // ErrNoKey returned if the key ID is invalid (or expired). ErrNoKey = errors.New("invalid key ID") // ErrInvalidAlgorithm returned if the algorithm is the wrong type. ErrInvalidAlgorithm = errors.New("invalid algorithm") // ErrTokenExpired returned if the JWT has expired. ErrTokenExpired = errors.New("token expired") // ErrTokenUsedBeforeIssued returned if the token is used prematurely. ErrTokenUsedBeforeIssued = errors.New("token used before issued") )
Functions ¶
func DetermineKey ¶
DetermineKey looks up the public key and confirms the algorithm.
Types ¶
type JWTTime ¶
JWTTime enforces JSON marshaling the time in seconds.
func (JWTTime) MarshalJSON ¶
MarshalJSON marshals the time as a UNIX timestamp in seconds.
func (*JWTTime) UnmarshalJSON ¶
UnmarshalJSON unmarshals the data assuming an integer timestamp in seconds.
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Email string `json:"email"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Role string `json:"role"` // Password won't be included with JSON response! Password string `json:"-"` // Issued indicates when the JWT token for this user was issued. Issued JWTTime `json:"iat,omitempty"` // Expires indicates when the JWT token for this user expires. Expires JWTTime `json:"exp,omitempty"` }
User represents an authenticated user account.
func VerifyUser ¶
VerifyUser validates and converts a JWT token.
Click to show internal directories.
Click to hide internal directories.