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 ¶
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.
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.