jwt

package
v1.0.101-beta.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jwt builds compact JWS tokens signed by a keysigner.Signer.

It deliberately depends only on the standard library plus the existing google/uuid dependency — no third-party JWT library is introduced, keeping go.mod free of new dependencies. The actual signing (and, for ECDSA, the ASN.1->r||s conversion) is delegated to the Signer implementation.

Index

Constants

View Source
const ClientAssertionType = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"

ClientAssertionType is the RFC 7523 client_assertion_type value used for JWT bearer client authentication at the token endpoint.

View Source
const GrantTypeJWTBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer"

GrantTypeJWTBearer is the RFC 7523 grant_type value for JWT bearer grants.

Variables

This section is empty.

Functions

func SignAttestation

func SignAttestation(ctx context.Context, signer keysigner.Signer, ref keysigner.KeyRef, pub crypto.PublicKey, nonce string, now time.Time) (string, error)

SignAttestation signs the registration attestation JWT. The selected public key is embedded in the JWS "jwk" header so the registration backend can bind it to the app during action=begin; the claims carry the server nonce as a proof-of-possession challenge.

func SignClientAssertion

func SignClientAssertion(ctx context.Context, signer keysigner.Signer, ref keysigner.KeyRef, clientID, audience string, now time.Time) (string, error)

SignClientAssertion mints a short-lived RFC 7523 client_assertion: it reads the registered key (it must already exist — bound at registration; a missing key is an error, not a reason to create a new unbound one), derives the JWS alg from the public key, and signs an assertion whose audience is the brand's accounts host. The server, holding the public key bound at registration, verifies it in place of client_secret. The protected header carries the RFC 7638 public-key thumbprint as kid so the server can select one key from the app's key set.

This is the model-independent glue: the assertion JWT is identical whether the server augments an existing grant (device_code/refresh_token) with client authentication or uses a dedicated jwt-bearer grant — only where the caller attaches it differs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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