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

Offen
#3,473 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
csharp, openapi

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
C#
Sterne
567
Forks
107
Ø Merge
1 Std. 19 Min.
Gemergte PRs (30 T.)
353

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus fluentcms/FluentCMS

Alle Issues in fluentcms/FluentCMS

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.