jose

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 3 Imported by: 0

README

JOSE

Build Status GoDoc

JOSE is a comprehensive set of JWT, JWS, and JWE libraries.

Why

The only other JWS/JWE/JWT implementations are specific to JWT, and none were particularly pleasant to work with.

These libraries should provide an easy, straightforward way to securely create, parse, and validate JWS, JWE, and JWTs.

Notes:

JWE is currently unimplemented.

Version 0.9:

Documentation

The docs can be found at [godoc.org] docs, as usual.

A gopkg.in mirror can be found at https://gopkg.in/jose.v1, thanks to @zia-newversion. (For context, see issue #30.)

JWS RFC
JWE RFC
JWT RFC

License

[MIT] license.

Documentation

Overview

Package jose implements some helper functions and types for the children packages, jws, jwt, and jwe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(b []byte) ([]byte, error)

Base64Decode decodes a base64-encoded byte slice.

func Base64Encode

func Base64Encode(b []byte) []byte

Base64Encode encodes a byte slice.

func DecodeEscaped

func DecodeEscaped(b []byte) ([]byte, error)

DecodeEscaped decodes a base64-encoded byte slice straight from a JSON structure. It assumes it's in the format: `"base64"`, but can handle cases where it's not.

func EncodeEscape

func EncodeEscape(b []byte) []byte

EncodeEscape base64-encodes a byte slice but escapes it for JSON. It'll return the format: `"base64"`

func Now added in v1.1.0

func Now() time.Time

Now returns the current time in UTC.

Types

type Encoder

type Encoder interface {
	// Base64 implies T -> JSON -> RawURLEncodingBase64
	Base64() ([]byte, error)
}

Encoder is satisfied if the type can marshal itself into a valid structure for a JWS.

type Header map[string]interface{}

Header implements a JOSE Header with the addition of some helper methods, similar to net/url.Values.

func (Header) Base64

func (h Header) Base64() ([]byte, error)

Base64 implements the Encoder interface.

func (Header) Del

func (h Header) Del(key string)

Del removes the value that corresponds with key from the Header.

func (Header) Get

func (h Header) Get(key string) interface{}

Get retrieves the value corresponding with key from the Header.

func (Header) Has

func (h Header) Has(key string) bool

Has returns true if a value for the given key exists inside the Header.

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for Header.

func (Header) Set

func (h Header) Set(key string, val interface{})

Set sets Claims[key] = val. It'll overwrite without warning.

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler for Header.

type Protected

type Protected Header

Protected Headers are base64-encoded after they're marshaled into JSON.

func (Protected) Base64

func (p Protected) Base64() ([]byte, error)

Base64 implements the Encoder interface.

func (Protected) Del

func (p Protected) Del(key string)

Del removes the value that corresponds with key from the Protected Header.

func (Protected) Get

func (p Protected) Get(key string) interface{}

Get retrieves the value corresponding with key from the Protected Header.

func (Protected) Has

func (p Protected) Has(key string) bool

Has returns true if a value for the given key exists inside the Protected Header.

func (Protected) MarshalJSON

func (p Protected) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for Protected.

func (Protected) Set

func (p Protected) Set(key string, val interface{})

Set sets Protected[key] = val. It'll overwrite without warning.

func (*Protected) UnmarshalJSON

func (p *Protected) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler for Protected.

Directories

Path Synopsis
Package crypto implements "SigningMethods" and "EncryptionMethods"; that is, ways to sign and encrypt JWS and JWEs, respectively, as well as JWTs.
Package crypto implements "SigningMethods" and "EncryptionMethods"; that is, ways to sign and encrypt JWS and JWEs, respectively, as well as JWTs.
Package jws implements JWSs per RFC 7515
Package jws implements JWSs per RFC 7515
Package jwt implements JWTs per RFC 7519
Package jwt implements JWTs per RFC 7519

Jump to

Keyboard shortcuts

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