jose

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2021 License: MIT Imports: 7 Imported by: 0

README

jose

Wrapper around gopkg.in/square/go-jose.v2 for convenient encoding and decoding JWT/JWE needed in OIDC applications.

Install

go get -u github.com/absurdlab/pkg/jose

Usage

// encoding
token, _ := jose.Encode().Claims(
    new(jwt.Claims).
        GenerateID().
        WithAudience("tester").
        WithExpiryInFuture(600).
        WithIssuedAtNow().
        WithSubject("test"),
    ).
    Claims(etc{Foo: "bar"}).
    Sign(jwks, jwa.ES256).
	CompactSerialize()

// decoding
var (
	standardClaims = new(jwt.Claims)
	extraClaims = new(etc)
)
_ = jose.Decode().
	Decrypt(jwks, jwa.RSA1_5).
	Verify(jwks, jwa.ES256).
	Decode(token, standardClaims, extraClaims)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecode = errors.New("decode token error")
View Source
var ErrEncode = errors.New("encode token error")

Functions

func Decode

func Decode() *decodeOptions

Decode is the entrypoint to configure the decoding process.

func Encode

func Encode() *encodeOptions

Encode is the entrypoint for configuring the encoding process.

Types

type Decoder

type Decoder interface {
	// Decode decrypts and/or verifies token and unmarshal the object into the list of destinations.
	Decode(token string, dest ...interface{}) error
}

Decoder abstracts JWS/JWE decoding.

type Encoder

type Encoder interface {
	// CompactSerialize produces a encoded JWT token.
	CompactSerialize() (string, error)
}

Encoder abstracts JWS/JWE encoding.

Directories

Path Synopsis
jwk

Jump to

Keyboard shortcuts

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