jwt

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 14 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// TypeJWT defines JWT type.
	TypeJWT = "JWT"

	// AlgorithmNone used to indicate unsecured JWT.
	AlgorithmNone = "none"
)

Variables

This section is empty.

Functions

func IsJWS added in v0.1.3

func IsJWS(s string) bool

IsJWS checks if JWT is a JWS of valid structure.

func IsJWTUnsecured added in v0.1.3

func IsJWTUnsecured(s string) bool

IsJWTUnsecured checks if JWT is an unsecured JWT of valid structure.

func UnsecuredJWTVerifier

func UnsecuredJWTVerifier() jose.SignatureVerifier

UnsecuredJWTVerifier provides verifier for unsecured JWT.

func VerifyEdDSA

func VerifyEdDSA(pubKey *verifier.PublicKey, message, signature []byte) error

VerifyEdDSA verifies EdDSA signature.

func VerifyRS256

func VerifyRS256(pubKey *verifier.PublicKey, message, signature []byte) error

VerifyRS256 verifies RS256 signature.

Types

type BasicVerifier

type BasicVerifier struct {
	// contains filtered or unexported fields
}

BasicVerifier defines basic Signed JWT verifier based on Issuer Claim and Key ID JOSE Header.

func NewVerifier

func NewVerifier(resolver KeyResolver) *BasicVerifier

NewVerifier creates a new basic Verifier.

func (BasicVerifier) Verify

func (v BasicVerifier) Verify(joseHeaders jose.Headers, payload, signingInput, signature []byte) error

Verify verifies JSON Web Token. Public key is fetched using Issuer Claim and Key ID JOSE Header.

type Claims

type Claims jwt.Claims

Claims defines JSON Web Token Claims (https://tools.ietf.org/html/rfc7519#section-4)

type JSONWebToken

type JSONWebToken struct {
	Headers jose.Headers

	Payload map[string]interface{}
	// contains filtered or unexported fields
}

JSONWebToken defines JSON Web Token (https://tools.ietf.org/html/rfc7519)

func NewSigned added in v0.1.3

func NewSigned(claims interface{}, headers jose.Headers, signer jose.Signer) (*JSONWebToken, error)

NewSigned creates new signed JSON Web Token based on input claims.

func NewUnsecured added in v0.1.3

func NewUnsecured(claims interface{}, headers jose.Headers) (*JSONWebToken, error)

NewUnsecured creates new unsecured JSON Web Token based on input claims.

func Parse

func Parse(jwtSerialized string, opts ...ParseOpt) (*JSONWebToken, error)

Parse parses input JWT in serialized form into JSON Web Token. Currently JWS and unsecured JWT is supported.

func (*JSONWebToken) DecodeClaims

func (j *JSONWebToken) DecodeClaims(c interface{}) error

DecodeClaims fills input c with claims of a token.

func (*JSONWebToken) LookupStringHeader

func (j *JSONWebToken) LookupStringHeader(name string) string

LookupStringHeader makes look up of particular header with string value.

func (*JSONWebToken) Serialize added in v0.1.3

func (j *JSONWebToken) Serialize(detached bool) (string, error)

Serialize makes (compact) serialization of token.

type KeyResolver

type KeyResolver interface {

	// Resolve resolves public key.
	Resolve(what, kid string) (*verifier.PublicKey, error)
}

KeyResolver resolves public key based on what and kid.

type KeyResolverFunc added in v0.1.3

type KeyResolverFunc func(what, kid string) (*verifier.PublicKey, error)

KeyResolverFunc defines function.

func (KeyResolverFunc) Resolve added in v0.1.3

func (k KeyResolverFunc) Resolve(what, kid string) (*verifier.PublicKey, error)

Resolve resolves public key.

type ParseOpt

type ParseOpt func(opts *parseOpts)

ParseOpt is the JWT Parser option.

func WithJWTDetachedPayload

func WithJWTDetachedPayload(payload []byte) ParseOpt

WithJWTDetachedPayload option is for definition of JWT detached payload.

func WithSignatureVerifier

func WithSignatureVerifier(signatureVerifier jose.SignatureVerifier) ParseOpt

WithSignatureVerifier option is for definition of JWT detached payload.

Jump to

Keyboard shortcuts

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