Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrExp define error for expiration date ErrExp = errors.New("Token expired") // ErrNbf define error for not before date ErrNbf = errors.New("Token cant be use right now") // ErrIat define error for Issued at date ErrIat = errors.New("Token create from future") // ErrIss define error for mismatch issuer ErrIss = errors.New("Issuer not match") // ErrEmptyIss define error for empty issuer ErrEmptyIss = errors.New("Issuer empty") )
Functions ¶
This section is empty.
Types ¶
type IToken ¶
type IToken interface { Sign(ctx context.Context, payload *Payload) (string, error) Verify(ctx context.Context, token string) (*Payload, error) }
IToken define interface
type Payload ¶
type Payload struct { Issuer string `json:"iss,omitempty"` Subject string `json:"sub,omitempty"` Audience []string `json:"aud,omitempty"` ExpirationTime *Time `json:"exp,omitempty"` NotBefore *Time `json:"nbf,omitempty"` IssuedAt *Time `json:"iat,omitempty"` JWTID string `json:"jti,omitempty"` }
Payload define basic JWT field
type SignAlgorithm ¶
type SignAlgorithm string
SignAlgorithm types
const HS256 SignAlgorithm = "HS365"
HS256 const
const HS512 SignAlgorithm = "HS512"
HS512 const
type Time ¶
Time define costume time type
func (*Time) MarshalJSON ¶
MarshalJSON is a function to marshaling field time
func (*Time) UnmarshalJSON ¶
UnmarshalJSON is a function to unmarshaling function for time-related claims.
type Token ¶
type Token struct { Issuer string SignKey string SignAlg SignAlgorithm PrivKey interface{} PublKey interface{} }
Token define jwt
Click to show internal directories.
Click to hide internal directories.