jose

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2015 License: MIT Imports: 2 Imported by: 0

README

JOSE

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, but should be completed in a week.

Version 0.9:

Currently not version 1.0 yet.

The API will be 100% solidified with the 1.0 release and no API-breaking changes will be made without incrementing the major version number.

Documentation

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

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"`

Types

type Encoder

type Encoder interface {
	// Base64 implies T -> JSON -> Base64
	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