jose

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

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) StringsClaim added in v1.2.0

func (c Claims) StringsClaim(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 https://tools.ietf.org/html/draft-ietf-jose-json-web-key-36#page-5

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 Claims, 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: header.claims.signature

func (*JWT) KeyID

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

type Signer

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

type SignerHMAC

type SignerHMAC struct {
	VerifierHMAC
}

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
	VerifierRSA
}

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