jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaimSet

type ClaimSet struct {
	// JWT 4.1 Registered Claim Names
	Issuer         string `json:"iss,omitempty"` // JWT 4.1.1
	Subject        string `json:"sub,omitempty"` // JWT 4.1.2
	Audience       string `json:"aud,omitempty"` // JWT 4.1.3
	ExpirationDate int64  `json:"exp,omitempty"` // JWT 4.1.4
	NotBefore      int64  `json:"nbf,omitempty"` // JWT 4.1.5
	IssuedAt       int64  `json:"iat,omitempty"` // JWT 4.1.6
	JWTId          string `json:"jti,omitempty"` // JWT 4.1.7
	// Public Claim Names JWT 4.2 or Private Claim Names JWT 4.3
	AdditionalClaims map[string]interface{} `json:"-"`
}

ClaimSet implements the JWT 4

func (*ClaimSet) IsValid

func (c *ClaimSet) IsValid(expected ClaimValidation) bool

type ClaimValidation

type ClaimValidation struct {
	Issuer   string
	Subject  string
	Audience string
	IssuedAt int64
	JWTId    string
}

type JWT

type JWT struct {
	Header   *jws.Header
	ClaimSet *ClaimSet
}

JWT represents a JWT token consisting of a JWS Header (JWS 4), a JWT Claimset (JWT 4)

func Decode

func Decode(message string) (*JWT, error)

func DecodeAndVerify

func DecodeAndVerify(message string, sv jwa.SignerVerifier) (*JWT, error)

DecodeAndVerify decodes the given message using the given SignerVerifier TODO (0x434D53): Check the SignerVerifier.Alg() matches the Algorithm given in the Header

func (*JWT) EncodeAndSign

func (j *JWT) EncodeAndSign(sv jwa.SignerVerifier) (string, error)

EncodeAndSign encodes and signs the JWT token using the given SignerVerifier TODO (0x434D53): Check the SignerVerifier.Alg() matches the Algorithm given in the Header

Jump to

Keyboard shortcuts

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