Documentation
¶
Overview ¶
Package jwt strictly parses, signs, and verifies a bounded signed JWT subset.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMalformed = errors.New("jwt: malformed token") ErrLimitExceeded = errors.New("jwt: limit exceeded") ErrUnsupportedAlgorithm = errors.New("jwt: unsupported algorithm") ErrInvalidSignature = errors.New("jwt: invalid signature") ErrInvalidClaims = errors.New("jwt: invalid claims") ErrKeyNotFound = errors.New("jwt: verification key not found") ErrAmbiguousKey = errors.New("jwt: ambiguous verification key") ErrInvalidOptions = errors.New("jwt: invalid options") )
Functions ¶
func Sign ¶
Example ¶
package main
import (
"fmt"
"github.com/shibukawa/tinygodriver/jwt"
)
func main() {
signer, err := jwt.NewHMACSigner([]byte("01234567890123456789012345678901"))
if err != nil {
panic(err)
}
raw, err := jwt.Sign(jwt.Header{}, jwt.Claims{Issuer: "issuer"}, signer)
if err != nil {
panic(err)
}
token, err := jwt.Parse(raw, jwt.ParseOptions{})
if err != nil {
panic(err)
}
fmt.Println(token.Header.Algorithm)
}
Output: HS256
Types ¶
type Claims ¶
type Claims struct {
Issuer string
Subject string
Audience []string
ExpiresAt *int64
NotBefore *int64
IssuedAt *int64
ID string
Raw map[string]json.RawMessage
}
func ParseAndVerify ¶
func ParseAndVerify(compact string, resolver KeyResolver, parseOptions ParseOptions, verifyOptions VerifyOptions) (Claims, error)
func Verify ¶
func Verify(token *Token, resolver KeyResolver, options VerifyOptions) (Claims, error)
func (Claims) MarshalJSON ¶
type HMACSigner ¶
type HMACSigner struct {
// contains filtered or unexported fields
}
func NewHMACSigner ¶
func NewHMACSigner(key []byte) (*HMACSigner, error)
func (*HMACSigner) Algorithm ¶
func (*HMACSigner) Algorithm() string
type JWKS ¶
type JWKS struct {
// contains filtered or unexported fields
}
func (*JWKS) ResolveKey ¶
func (set *JWKS) ResolveKey(header Header) (VerificationKey, error)
type JWKSOptions ¶
type KeyResolver ¶
type KeyResolver interface {
ResolveKey(header Header) (VerificationKey, error)
}
type KeyResolverFunc ¶
type KeyResolverFunc func(header Header) (VerificationKey, error)
func (KeyResolverFunc) ResolveKey ¶
func (resolve KeyResolverFunc) ResolveKey(header Header) (VerificationKey, error)
type ParseOptions ¶
type Token ¶
type VerificationKey ¶
Click to show internal directories.
Click to hide internal directories.