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

Abierto
#3,473 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp, openapi

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C#
Estrellas
567
Forks
107
Merge medio
1 h 19 min
PR fusionados (30 d)
353

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fluentcms/FluentCMS

Todos los issues de fluentcms/FluentCMS

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.