jwsutil

package
v1.0.0-alpha-1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package jwsutil provides serialization utilities for JWT libraries to comfort JWS. Reference: RFC 7515 JSON Web Signature (JWS).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCompactSerialization = errors.New("invalid compact serialization")
	ErrInvalidJSONSerialization    = errors.New("invalid JSON serialization")
)

Common errors

Functions

This section is empty.

Types

type CompleteSignature

type CompleteSignature struct {
	Payload string `json:"payload,omitempty"`
	Signature
}

CompleteSignature represents a clear signed signature. A CompleteSignature can be viewed as an envelope with a single signature in flattened JWS JSON serialization syntax. Reference: RFC 7515 7.2 JWS JSON Serialization.

func ParseCompact

func ParseCompact(serialized string) (CompleteSignature, error)

Parse parses the compact serialized JWS. Reference: RFC 7515 7.1 JWS Compact Serialization.

func (CompleteSignature) Enclose

func (s CompleteSignature) Enclose() Envelope

Enclose packs the signature into an envelope.

func (CompleteSignature) SerializeCompact

func (s CompleteSignature) SerializeCompact() string

SerializeCompact serialize the signature in JWS Compact Serialization Reference: RFC 7515 7.1 JWS Compact Serialization.

type Envelope

type Envelope struct {
	Payload    string      `json:"payload,omitempty"`
	Signatures []Signature `json:"signatures,omitempty"`
}

Envelope contains a common payload signed by multiple signatures.

func (Envelope) Open

func (e Envelope) Open() CompleteSignature

Open opens the evelope and returns the first or default complete signature.

func (Envelope) Size

func (e Envelope) Size() int

Size returns the number of enclosed signatures.

func (*Envelope) UnmarshalJSON

func (e *Envelope) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the JSON serialized JWS. Reference: RFC 7515 7.2 JWS JSON Serialization.

type Signature

type Signature struct {
	Protected   string          `json:"protected,omitempty"`
	Unprotected json.RawMessage `json:"header,omitempty"`
	Signature   string          `json:"signature,omitempty"`
}

Signature represents a detached signature.

Jump to

Keyboard shortcuts

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