Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidKey = errors.New("invalid key length, must be 32 bytes")
)
Functions ¶
This section is empty.
Types ¶
type DataWithClaims ¶
DataWithClaims holds user data with jwt.Claims
type Decoder ¶
type Decoder interface {
Decode(string, DataWithClaims, ...DecoderOpts) error
}
Decoder decodes a token into DataWithClaims
func MustNewDecoder ¶
func MustNewDecoder(key []byte, opts ...DecoderOpts) Decoder
MustNewDecoder returns a new JWE decoder, panics on error
func NewDecoder ¶
func NewDecoder(key []byte, opts ...DecoderOpts) (Decoder, error)
NewDecoder returns a new JWE decoder
type DecoderOpts ¶
DecoderOpts represents options applied to each token
func DecoderWithIssuer ¶
func DecoderWithIssuer(issuer string) DecoderOpts
DecoderWithIssuer will expect Issuer to match
func DecoderWithSubject ¶
func DecoderWithSubject(subject string) DecoderOpts
DecoderWithSubject will expect Subject to match
func DecoderWithTime ¶
func DecoderWithTime() DecoderOpts
DecoderWithTime will expect claim to be valid in current time
type EmbedJWTClaims ¶
EmbedJWTClaims contains jwt.Claims Embed this in user structures to use with Encoder and Decoder interfaces
func (*EmbedJWTClaims) GetClaims ¶
func (e *EmbedJWTClaims) GetClaims() *jwt.Claims
GetClaims returns the embedded jwt.Claims
type Encoder ¶
type Encoder interface {
Encode(DataWithClaims, ...EncoderOpts) (string, error)
}
Encoder encodes DataWithClaims into a token
func MustNewEncoder ¶
func MustNewEncoder(key []byte, opts ...EncoderOpts) Encoder
MustNewEncoder returns a JWE encoder panics on wrong key length
func NewEncoder ¶
func NewEncoder(key []byte, opts ...EncoderOpts) (Encoder, error)
NewEncoder returns a JWE encoder expects a 16, 24 or 32 byte length key
type EncoderOpts ¶
EncoderOpts represents options applied to each token
func EncoderWithAge ¶
func EncoderWithAge(age time.Duration) EncoderOpts
EncoderWithAge will set expiry according to current time and given duration
func EncoderWithIssuer ¶
func EncoderWithIssuer(issuer string) EncoderOpts
EncoderWithIssuer will set Issuer
func EncoderWithSubject ¶
func EncoderWithSubject(subject string) EncoderOpts
EncoderWithSubject will set Issuer