jwtverifier

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package jwtverifier provides JWT claim extraction and verification backends.

The package supports three modes:

  • ESPv1: Extract claims from X-Endpoint-API-UserInfo header set by Cloud Endpoints
  • Direct: Validate JWT from Authorization header using JWKS
  • Insecure: Parse JWT without validation (development/testing only)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direct

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

Direct validates JWTs from the Authorization header using JWKS. This mode fetches the JWKS on every request (no caching) and validates the JWT signature. Intended for integration testing, not production use.

func NewDirect

func NewDirect(jwksURL *url.URL) (*Direct, error)

NewDirect creates a new direct JWT verifier with JWKS validation.

func (*Direct) ExtractClaims

func (v *Direct) ExtractClaims(req *http.Request) (map[string]interface{}, error)

ExtractClaims extracts and validates JWT claims from the Authorization header. It fetches the JWKS on every request and validates the JWT signature. This is only meant to be used for local e2e testing. TODO: implement proper caching and JWKS reuse to allow non-GAE deployments.

func (*Direct) Mode

func (v *Direct) Mode() string

Mode returns the verification mode name.

type ESPv1

type ESPv1 struct{}

ESPv1 extracts JWT claims from the X-Endpoint-API-UserInfo header set by Cloud Endpoints ESPv1 after JWT validation.

func NewESPv1

func NewESPv1() *ESPv1

NewESPv1 creates a new ESPv1 JWT verifier.

func (*ESPv1) ExtractClaims

func (v *ESPv1) ExtractClaims(req *http.Request) (map[string]interface{}, error)

ExtractClaims extracts JWT claims from the X-Endpoint-API-UserInfo header.

func (*ESPv1) Mode

func (v *ESPv1) Mode() string

Mode returns the verification mode name.

type Insecure

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

Insecure parses JWTs from the Authorization header WITHOUT signature verification. This mode is ONLY for development and testing. It requires the ALLOW_INSECURE_JWT=true environment variable to be set as a safety check.

WARNING: Never use this in production - it accepts any JWT regardless of signature.

func NewInsecure

func NewInsecure() (*Insecure, error)

NewInsecure creates a new insecure JWT verifier. Returns an error if the ALLOW_INSECURE_JWT environment variable is not set to "true".

func (*Insecure) ExtractClaims

func (v *Insecure) ExtractClaims(req *http.Request) (map[string]interface{}, error)

ExtractClaims extracts JWT claims from the Authorization header without signature verification.

func (*Insecure) Mode

func (v *Insecure) Mode() string

Mode returns the verification mode name.

Jump to

Keyboard shortcuts

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