pub fn generate_token(secret: &Key, ttl: Duration) -> StringExpand description
Mint a self-expiring authentication token valid for ttl from now, signed
with secret.
This is the free-standing form of AuthConfig::generate_token: a token depends only on the persistent secret, so callers that mint tokens (often on a rotation timer) can do so without building — or cloning — a whole AuthConfig. Pass the same Key that the AuthConfig::persistent_secret driving the AuthLayer uses, otherwise the minted token will not validate.
The returned string is the value to place in the TokenConfig::name query
parameter of the initial URL handed to the user out-of-band. Prefer a short
ttl: a token only needs to live long enough for the first request, after
which the client holds a session cookie. An absurdly large ttl saturates at
the maximum representable expiry rather than panicking.