jws

package
v1.0.0-dev.17 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package jws verifies a compact JWS (RFC 7515) carrying a signed JWT (RFC 7519) under the algorithms of package jwk, and returns its payload. It knows nothing of OpenID Connect.

Index

Constants

View Source
const MaxSize = 64 << 10

MaxSize is the longest token Parse reads; a longer one is refused before any part is decoded (Authlib CVE-2025-61920).

Variables

View Source
var (
	// ErrInvalid is the error Parse wraps when it refuses a token.
	ErrInvalid = errors.New("jws: token refused")
	// ErrNoKey is the error Verify returns when no key of the set fits the
	// token and verifies its signature: a miss, which a fresher set may fix.
	ErrNoKey = errors.New("jws: no key verifies the token")
)

Functions

This section is empty.

Types

type Token

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

Token is a parsed compact JWS whose header passed every check.

func Parse

func Parse(token string, allowed []jwk.Alg) (*Token, error)

Parse checks a compact JWS's size, shape, encoding and header, and that its alg names one of the allowed rows, before any key is chosen. Every refusal wraps ErrInvalid.

func (*Token) Verify

func (t *Token) Verify(keys jwk.Set) ([]byte, error)

Verify tries every key of keys that fits the token's alg and, when the header names a kid, carries that exact kid (RFC 7515 §4.1.4); it returns the payload under the first that verifies the signature, or ErrNoKey.

Jump to

Keyboard shortcuts

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