Version: v0.1.0 Latest Latest

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

Go to latest
Published: Sep 3, 2015 License: Apache-2.0 Imports: 14 Imported by: 0




View Source
const (
	HeaderMediaType    = "typ"
	HeaderKeyAlgorithm = "alg"
	HeaderKeyID        = "kid"


This section is empty.


This section is empty.


type Claims

type Claims map[string]interface{}

func (Claims) Add

func (c Claims) Add(name string, value interface{})

func (Claims) Int64Claim

func (c Claims) Int64Claim(name string) (int64, bool, error)

func (Claims) StringClaim

func (c Claims) StringClaim(name string) (string, bool, error)

func (Claims) TimeClaim

func (c Claims) TimeClaim(name string) (time.Time, bool, error)

type JOSEHeader

type JOSEHeader map[string]string

func (JOSEHeader) Validate

func (j JOSEHeader) Validate() error

type JWK

type JWK struct {
	ID       string
	Type     string
	Alg      string
	Use      string
	Exponent int
	Modulus  *big.Int
	Secret   []byte

JSON Web Key

func (*JWK) MarshalJSON

func (j *JWK) MarshalJSON() ([]byte, error)

func (*JWK) UnmarshalJSON

func (j *JWK) UnmarshalJSON(data []byte) error

type JWS

type JWS struct {
	RawHeader  string
	Header     JOSEHeader
	RawPayload string
	Payload    []byte
	Signature  []byte

func ParseJWS

func ParseJWS(raw string) (JWS, error)

Given a raw encoded JWS token parses it and verifies the structure.

type JWT

type JWT JWS

func NewJWT

func NewJWT(header JOSEHeader, claims Claims) (jwt JWT, err error)

func NewSignedJWT

func NewSignedJWT(claims map[string]interface{}, s Signer) (*JWT, error)

func ParseJWT

func ParseJWT(token string) (jwt JWT, err error)

func (*JWT) Claims

func (j *JWT) Claims() (Claims, error)

func (*JWT) Data

func (j *JWT) Data() string

Encoded data part of the token which may be signed.

func (*JWT) Encode

func (j *JWT) Encode() string

Full encoded JWT token string in format:

func (*JWT) KeyID

func (j *JWT) KeyID() (string, bool)

type Signer

type Signer interface {
	Sign(data []byte) (sig []byte, err error)

type SignerHMAC

type SignerHMAC struct {

func NewSignerHMAC

func NewSignerHMAC(kid string, secret []byte) *SignerHMAC

func (*SignerHMAC) Sign

func (s *SignerHMAC) Sign(data []byte) ([]byte, error)

type SignerRSA

type SignerRSA struct {
	PrivateKey rsa.PrivateKey

func NewSignerRSA

func NewSignerRSA(kid string, key rsa.PrivateKey) *SignerRSA

func (*SignerRSA) Sign

func (s *SignerRSA) Sign(data []byte) ([]byte, error)

type Verifier

type Verifier interface {
	ID() string
	Alg() string
	Verify(sig []byte, data []byte) error

func NewVerifier

func NewVerifier(jwk JWK) (Verifier, error)

type VerifierHMAC

type VerifierHMAC struct {
	KeyID  string
	Hash   crypto.Hash
	Secret []byte

func NewVerifierHMAC

func NewVerifierHMAC(jwk JWK) (*VerifierHMAC, error)

func (*VerifierHMAC) Alg

func (v *VerifierHMAC) Alg() string

func (*VerifierHMAC) ID

func (v *VerifierHMAC) ID() string

func (*VerifierHMAC) Verify

func (v *VerifierHMAC) Verify(sig []byte, data []byte) error

type VerifierRSA

type VerifierRSA struct {
	KeyID     string
	Hash      crypto.Hash
	PublicKey rsa.PublicKey

func NewVerifierRSA

func NewVerifierRSA(jwk JWK) (*VerifierRSA, error)

func (*VerifierRSA) Alg

func (v *VerifierRSA) Alg() string

func (*VerifierRSA) ID

func (v *VerifierRSA) ID() string

func (*VerifierRSA) Verify

func (v *VerifierRSA) Verify(sig []byte, data []byte) error

Jump to

Keyboard shortcuts

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