Skip to content

Renew a State token once it is past half its lifetime #856

Done

Description

@JuroOravec

A signed State token expires _max_age (24 hours by default) after Citry issued it. Citry issues a new token only when it renders the component or when a call changes State. So a page that is in use, but whose calls never change State, gets stale_state and a reload prompt once the token is old enough. This came up in #852.

Proposal: when a call arrives with a valid token that is past half its lifetime, Citry issues a new token in the response, with a full new _max_age, even if State did not change. This is how session cookies are usually renewed.

  • A page that is in use never expires. A page left idle still expires after _max_age.
  • The cost is at most one extra State refresh per half-lifetime (every 12 hours by default). The fresh token rides the existing state action, so the protocol does not change.
  • Calls that carry no token (GET handlers that do not read State) cannot renew it, as today.

Replay: a copied token can already get a new lifetime through any call that changes State, so renewing on read-only calls adds little. Tokens stay bound to their component class and protocol version, not to a user or session, as security.md says. The PR should still go through the Mechanism 7 review.

Release: a new feature, so a minor release (1.3.0). Update the State lifetime docs from #852/#855 and docs/design/events.md section 7.1 in the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions