jwt

package
Version: v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package jwt implements encoding/decoding for JSON Web Token claims (RFC7519).

If you need to handle authentication tokens in common use cases, the KISStokens/opinionated package might be a better fit. If you do have special requirements exceeding the capabilities of KISStokens/opinionated, this package is intended to be used together with the KISStokens/jws package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClaimNameCollision     = errors.New("the name of a custom claim collides with the name of a standard claim")
	ErrClaimsMustBeJSONObject = errors.New("the encoded claims must be a JSON Object")
	ErrMarshallingFailed      = errors.New("could not marshal claims set to JSON")
)

Functions

This section is empty.

Types

type Claims

type Claims struct {
	StandardClaims
	CustomClaims map[string]interface{}
}

Claims represents the claims of a JSON Web Token

func ParseClaims

func ParseClaims(input []byte) (*Claims, error)

ParseClaims parses JWT Claims from the given JSON input

func (*Claims) Serialize

func (c *Claims) Serialize() ([]byte, error)

Serialize serializes the claim set to JSON It will not accept claim sets that have a custom claim with the same key as a standard claim.

type StandardClaims

type StandardClaims struct {
	Issuer         *string
	Subject        *string
	Audience       []string
	ExpirationTime *time.Time
	NotBefore      *time.Time
	IssuedAt       *time.Time
	JwtId          *string
}

StandardClaims represents the registered JWT claims as defined in RFC7519 When parsing, claims that were not present are set to nil.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL