Why carry a token
The server receiving a form may not be the server that observed the browser’s connection. A connection token is a protected record that carries selected observations from the observing service to the receiving application.
The page obtains the token before submitting the form, then includes it with the submission. The application validates the token and compares its context with the action being requested.
Browser ── observation request ──> Observing service
Browser <── protected token ───── Observing service
Browser ── form and token ───────> Application server
validates token and submission context
This chapter explains the design pattern. The fields and validation rules of a particular service belong to that service’s contract.
Protecting contents and keeping them secret
Two properties matter separately. Integrity protection lets the recipient detect unauthorised changes. Encryption limits who can read the contents.
A signed token can provide integrity while leaving its payload readable. Encoding a payload for transport does not encrypt it. An encrypted token can also authenticate the protected contents, using authenticated encryption. RFC 5116 defines an interface for authenticated encryption with associated data: decryption returns the plaintext or an authentication failure.
With an encrypted token, the browser can carry an opaque value without reading the observations inside it. The server must still validate the authenticated contents before using them. A protected record of an observation does not make the observation infallible.
What a token can carry
A design can carry the inputs to later comparisons, the results of earlier checks, or a combination of both.
| Information | Purpose | Remaining limit |
|---|---|---|
| Issue and expiry times | Bound the age of the record | A current token can still be copied |
| Intended recipient or application | Prevent use in an unrelated context | The recipient must actually validate this binding |
| Random token identifier | Let the application recognise repeated use | Recognising use requires a record outside the token |
| Selected connection context | Compare collection with the later submission | Addresses and browser declarations can change legitimately |
| Check outcomes and availability | Carry evidence without all the raw observations | Missing evidence remains missing after packaging |
For JWT designs, RFC 8725 requires validating the audience when the issuer serves multiple recipients. The same underlying question applies to other formats: was this token intended for this application and this use?
Expiry and replay answer different questions
An expiry time answers whether a token is still within its permitted lifetime. Replay means presenting a previously issued token again. Reusing a token need not change any bytes, so its cryptographic check can still pass.
To enforce single use, the application needs to record consumption and reject another use of the same identifier. The check and the protected action must be coordinated so that simultaneous requests cannot both pass an earlier “unused” check.
The JWT identifier described in RFC 7519 §4.1.7 can support replay prevention. Including an identifier alone does not provide that prevention; the recipient’s handling of it matters.
Compare context without assuming a permanent identity
A token can describe the address or browser claim observed when it was issued. The application can compare those values with the later request, but the meaning of a difference depends on the context.
A mobile device can move between Wi-Fi and a carrier network. Browser updates and privacy tools can change declarations. Shared NAT also means that an address match is compatible with unrelated devices.
A visitor identifier can add profile continuity, subject to the limits of browser storage. It does not prove a person’s identity, and a stable profile can remain under automated control.
Keep refresh rules and key access explicit
A long form may need fresh evidence before submission. Refreshing a token raises a design question: which earlier context, if any, may the new record inherit? Inheriting an earlier start time without checking continuity can give the later action a misleading history.
Key access defines another boundary. In a symmetric encryption design, a party holding the sealing key can generally create tokens as well as read them. With a digital signature, possession of a verification key alone does not grant signing authority. These are different trust arrangements, even when both produce a token the application can validate.
Keep validation outcomes distinct
A missing token, an expired token, an authentication failure and an unsupported format describe different failures. They need different investigation and recovery paths. A deployment mismatch can make a newly issued format unreadable; a blocked script can prevent collection entirely.
The same distinction applies inside a valid token. A check that did not run has not returned a negative result. Read browser probes for unavailable observations and evidence statistics for turning available evidence into an application decision.
For a concrete browser-to-server flow, see the Sharp Signals integration. It starts with a visit evaluation without email and explains the token lifetime, refresh, request retries and the separate charge for a new evaluation. The current API’s action retains signup-policy semantics; it is not a general challenge or a guarantee of single-use enforcement for your application action.