kmsjwt

package module
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 10 Imported by: 0

README

kmsjwt

Godoc CircleCI Go Report Card codecov

This little utility library provides an AWS KMS-based implementation of jwt.SigningMethod.

You will be using an instance of context.Context as the encryption key.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("key is invalid")

ErrInvalidKey indicates taht the key is invalid.

View Source
var ErrKmsVerification = errors.New("kms: verification error")

ErrKmsVerification is an error shown when KMS token verification fails.

Functions

func DisableCache

func DisableCache(k *KMSJWT)

DisableCache disables cache on the client (on by default).

Types

type KMSJWT

type KMSJWT struct {
	kmsiface.KMSAPI
	// contains filtered or unexported fields
}

func New

func New(client kmsiface.KMSAPI, kmsKeyID string, opts ...Option) *KMSJWT

New provides a KMS-based implementation of JWT signing method.

func (*KMSJWT) Alg

func (k *KMSJWT) Alg() string

func (*KMSJWT) Sign

func (k *KMSJWT) Sign(signingString string, key interface{}) (string, error)

func (*KMSJWT) Verify

func (k *KMSJWT) Verify(signingString, stringSignature string, key interface{}) error

type Option

type Option func(*KMSJWT)

Option is a function that modifies the way the verification method works.

func WithAlgorithm

func WithAlgorithm(algorithm string) Option

func WithCleanupInterval

func WithCleanupInterval(cleanupInterval time.Duration) Option

WithCleanupInterval changes the key cleanup interval if the cache is "on". By default, it's one minute.

func WithDefaultExpiration

func WithDefaultExpiration(defaultExpiration time.Duration) Option

WithDefaultExpiration changes the default key expiration if the cache is "on". By default, cache expires after an hour.

func WithSigningAlgorithm

func WithSigningAlgorithm(algorighm string) Option

WithSigningAlgorithm changes the algorighm used to sign and verify tokens. By default, "RSAES_OAEP_SHA_256" is used.

Jump to

Keyboard shortcuts

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