The preview token answer does not say how long the token lasts, so an admin on another origin cannot reuse one

オープン
#3,473 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp, openapi

調査の方向性

Start with the preview-token endpoint and response model, then read PreviewTokenOptions and the OpenAPI document and client definitions. Check how the endpoint computes expiresAt and how configured or requested lifetimes are applied. Done when the response includes the issued lifetime in seconds and the OpenAPI document and both clients include the member.

索引モデルが issue の本文から書いたものです。

説明

area:api area:publishing type:feature

Problem

The answer of a preview token mint gives expiresAt, a moment on the server's clock, and the server checks it with no skew. The admin runs in the browser, whose clock may differ by minutes, so it cannot tell from expiresAt alone how long the token it holds still lasts. It reads the response's Date header to measure the server's clock (#3437), but:

  • an admin on another origin never sees Date: CORS does not safelist it, and the Management API's policy exposes only ETag, Location, Retry-After and the rate limit headers (src/FluentCMS.Core/Api/Common/CorsPolicies.cs, lines 17 and 36);
  • a reverse proxy may write its own Date (nginx does by default);
  • the lifetime is the operator's (PreviewTokenOptions.DefaultLifetime, from 1 minute up to MaximumLifetime), so the admin cannot assume ten minutes.

Without either, the admin mints a new token on every save and every Reload, and a token cannot be revoked.

Proposal

Add to the answer of POST .../preview-token the token's lifetime in whole seconds as issued (for instance expiresIn), beside expiresAt. The admin then takes the deadline as its own clock at the request plus that lifetime, whatever the skew and whatever proxy is in front. It adds to an answer and changes no model. The OpenAPI document and the clients take the member.

Acceptance

  • The mint answer carries the token's lifetime in seconds, equal to expiresAt minus the moment of issue
  • A configured DefaultLifetime and a requested lifetime are both reflected
  • The OpenAPI document and the two clients have the member

For workstation B (#3356). Asked for by #3437 (#3403): until it is merged, an admin that sees no Date header mints on every save and every Reload, as before #3437.

主要言語
C#
スター
567
フォーク
107
平均マージ
1時間 19分
マージ済み PR(30日)
353

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluentcms/FluentCMS のほかの issue

fluentcms/FluentCMS の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。