Runway 1.1.1

This commit is contained in:
Runway committed 2026-10-29 11:41:13 -06:00
1 parent 07d5bd7e9a
commit 67d61f339c
28 files changed
+826 -38

No files matched your search

@@ -49,10 +49,13 @@ public class AppBackupsController {
private final AppActivityLog activity;
private final mx.quest.runway.backup.BackupProperties policy;
private final mx.quest.runway.platform.PlatformSettingsStore platform;
public AppBackupsController(SiteStore sites, BackupService backups, PlatformAuthority platformAuthority,
@Qualifier("operatorAwareMessageSource") MessageSource messages,
AppActivityLog activity, mx.quest.runway.backup.BackupProperties policy) {
AppActivityLog activity, mx.quest.runway.backup.BackupProperties policy,
mx.quest.runway.platform.PlatformSettingsStore platform) {
this.platform = platform;
this.policy = policy;
this.sites = sites;
this.backups = backups;
@@ -61,6 +64,9 @@ public class AppBackupsController {
this.activity = activity;
}
/** Flash attribute naming the site whose hosts the Backups screen shows for review after a restore. */
static final String REVIEW_HOSTS = "reviewHostsOf";
/** One site row: its id and the backups stored for it on the server. */
public record SiteBackups(String siteId, List<StoredBackup> stored) {
}
@@ -73,6 +79,15 @@ public class AppBackupsController {
rows.add(new SiteBackups(site.id(), backups.list(site.id())));
}
model.addAttribute("rows", rows);
// After a restore (or a site created from a backup), how the site is reached now: the hosts and base URL may
// have come from the backup, so they are shown for review with the editor, read from the store as they stand.
if (model.getAttribute(REVIEW_HOSTS) instanceof String reviewed) {
sites.find(reviewed).ifPresent(site -> {
model.addAttribute("reviewSite", site);
// A site with no host is reached only if it is the default (catch-all) site; otherwise not at all.
model.addAttribute("reviewIsDefault", platform.get().defaultSite().filter(reviewed::equals).isPresent());
});
}
// Shown, not edited: a server folder that receives every site's archives is the host's (settings-homes.yml).
String offsite = policy.getOffsiteDir();
model.addAttribute("offsiteDir", offsite == null || offsite.isBlank() ? null : offsite.trim());
@@ -136,6 +151,7 @@ public class AppBackupsController {
backups.restore(siteId, in);
activity.record(authentication.getName(), "site.restored", siteId + " (upload)");
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
redirect.addFlashAttribute(REVIEW_HOSTS, siteId);
} catch (UnsupportedBackupFormatException e) {
redirect.addFlashAttribute("error", newerFormat(e));
} catch (IOException | RuntimeException e) {
@@ -154,6 +170,7 @@ public class AppBackupsController {
backups.restoreStored(siteId, name);
activity.record(authentication.getName(), "site.restored", siteId + "/" + name);
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
redirect.addFlashAttribute(REVIEW_HOSTS, siteId);
} catch (UnsupportedBackupFormatException e) {
redirect.addFlashAttribute("error", newerFormat(e));
} catch (IOException | RuntimeException e) {
@@ -196,6 +213,7 @@ public class AppBackupsController {
backups.createFromBackup(newId.strip(), name, splitHosts(hosts), in);
activity.record(authentication.getName(), "site.created-from-backup", newId.strip());
redirect.addFlashAttribute("flash", message("op.appbackups.created", "Site created from backup."));
redirect.addFlashAttribute(REVIEW_HOSTS, newId.strip());
} catch (UnsupportedBackupFormatException e) {
redirect.addFlashAttribute("error", newerFormat(e));
} catch (IllegalStateException e) {
@@ -61,10 +61,13 @@ public class TenantBackupsController {
private final TenantAuthority tenantAuthority;
private final MessageSource messages;
private final mx.quest.runway.backup.BackupProperties policy;
private final mx.quest.runway.platform.PlatformSettingsStore platform;
public TenantBackupsController(SiteResolver siteResolver, BackupService backups, TenantAuthority tenantAuthority,
@Qualifier("operatorAwareMessageSource") MessageSource messages,
mx.quest.runway.backup.BackupProperties policy) {
mx.quest.runway.backup.BackupProperties policy,
mx.quest.runway.platform.PlatformSettingsStore platform) {
this.platform = platform;
this.policy = policy;
this.siteResolver = siteResolver;
this.backups = backups;
@@ -84,6 +87,12 @@ public class TenantBackupsController {
model.addAttribute("backupPolicyKeepKey", "op.backups.policy.keep."
+ (count > 0 ? "count" : "all") + (days > 0 ? "Days" : ""));
model.addAttribute("transferOmissions", transferOmissions(site.id()));
// After a restore: how the site is reached, for review. A restore from this console keeps the hosts and base URL
// (only the application console changes them), so they are shown as they stand, without an editor.
if (Boolean.TRUE.equals(model.getAttribute(AppBackupsController.REVIEW_HOSTS))) {
model.addAttribute("reviewSite", site);
model.addAttribute("reviewIsDefault", platform.get().defaultSite().filter(site.id()::equals).isPresent());
}
// Restore is destructive + master-only; hide its affordances from a non-master (the controller still enforces).
boolean admin = tenantAuthority.isTenantAdmin(authentication, site.id());
model.addAttribute("canRestore", admin);
@@ -196,6 +205,7 @@ public class TenantBackupsController {
try {
backups.restoreStored(site.id(), name, true); // a site manager never changes how the site is reached
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
redirect.addFlashAttribute(AppBackupsController.REVIEW_HOSTS, Boolean.TRUE);
} catch (UnsupportedBackupFormatException e) {
redirect.addFlashAttribute("error", newerFormat(e));
} catch (IOException | RuntimeException e) {
@@ -218,6 +228,7 @@ public class TenantBackupsController {
try (InputStream in = file.getInputStream()) {
backups.restore(site.id(), in, true); // a site manager never changes how the site is reached
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
redirect.addFlashAttribute(AppBackupsController.REVIEW_HOSTS, Boolean.TRUE);
} catch (UnsupportedBackupFormatException e) {
redirect.addFlashAttribute("error", newerFormat(e));
} catch (IOException | RuntimeException e) {
@@ -0,0 +1,167 @@
package mx.quest.runway.web;
import java.nio.ByteBuffer;
import org.eclipse.jetty.http.HttpException;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.util.Callback;
/**
* Refuses a request body that arrives more slowly than a minimum rate, on <b>every</b> read of the body: the
* servlet input stream, form parameters and multipart parts alike.
*
* <p><b>Why a handler of our own.</b> Jetty 12's own minimum request data rate is checked only where a servlet reads
* the body through {@code getInputStream()}. Form parameters ({@code getParameter}, which Spring Security's login
* reads) and multipart parts are parsed through Jetty's core request instead, and that path never checks it, so a
* client could trickle a form for as long as it kept sending something inside each idle interval, holding a request
* thread all the while. Measured on 1.1.0: form and multipart posts dripped at 20 bytes a second were held until the
* 30-second idle timeout. This handler sits under the server and wraps the core request, so every body read passes
* through it.
*
* <p><b>What is measured.</b> Only the time spent <em>waiting for the client</em>: from a read that found no data to
* the next one that did. Time the application spends before or between reads does not count, so a server that is
* slow to read is never blamed. The check keeps a balance: every byte received earns one, every second of waiting
* costs the rate's worth, and the balance is capped at {@link #CREDIT_SECONDS} of the rate, so a body sent fast at
* first cannot buy an hour of dripping later. It runs when data arrives: once the waiting time reaches one second and
* the balance is negative, the read fails with {@code 408 Request Timeout} and so does every later read. A client
* pausing between packets is therefore cut when its next packet arrives, at most one idle timeout later. A chunk that completes the body is never refused: once the client has finished, no thread
* is waiting on it any more, and a small form whose only packet arrived late (a network stall) is not punished for
* it; the body counts as complete at its last chunk or, with a {@code Content-Length}, at its last byte. A client that
* sends nothing at all is left to the connection idle timeout.
*
* <p>The refusal is answered {@code 408} however the application handled the failed read: a form or multipart parser
* would report it as {@code 400}, as if the body were malformed, and code reading the stream itself could leave an
* empty {@code 200} (see {@link RefusalStatusResponse}).
*/
final class RequestBodyRateHandler extends Handler.Wrapper {
/** Waiting shorter than this is never judged: a single network stall must not look like a slow client. */
static final long GRACE_NANOS = 1_000_000_000L;
/**
* The most waiting a body may have banked by arriving fast earlier: 30 seconds' worth of the rate, the connection
* idle timeout's default. Without a cap, a client that sent most of a large body at line speed and then dripped
* the rest could hold the thread for the body's size divided by the rate (16 MiB at 4 KiB/s: over an hour).
*/
static final long CREDIT_SECONDS = 30;
private final long bytesPerSecond;
private final long creditSeconds;
/** @param bytesPerSecond the slowest a body may arrive; must be positive (0 means "do not install") */
RequestBodyRateHandler(long bytesPerSecond) {
this(bytesPerSecond, CREDIT_SECONDS);
}
/** As {@link #RequestBodyRateHandler(long)}, with the credit cap in seconds (tests use a short one). */
RequestBodyRateHandler(long bytesPerSecond, long creditSeconds) {
if (bytesPerSecond <= 0 || creditSeconds <= 0) {
throw new IllegalArgumentException("rate and credit must be positive: " + bytesPerSecond + ", "
+ creditSeconds);
}
this.bytesPerSecond = bytesPerSecond;
this.creditSeconds = creditSeconds;
}
long bytesPerSecond() {
return bytesPerSecond;
}
@Override
public boolean handle(Request request, Response response, Callback callback) throws Exception {
RateCheckedRequest checked = new RateCheckedRequest(request, bytesPerSecond, creditSeconds);
return super.handle(checked, new RefusalStatusResponse(checked, response), callback);
}
/**
* Keeps the refusal's status. A form or multipart parser reports any failed read as {@code 400 Bad Request}
* ("unable to parse form content"), which would tell the client its body was malformed when it was only slow; and
* code that reads the stream itself lets the failure escape as an {@code IOException}, which Jetty handles like a
* client that went away, completing the response with the status it already had ({@code 200}, empty). Once this
* request's body was refused, a client error status set on the response becomes {@code 408}, and so does whatever
* status the response is committed with.
*/
private static final class RefusalStatusResponse extends Response.Wrapper {
private final RateCheckedRequest request;
RefusalStatusResponse(RateCheckedRequest request, Response wrapped) {
super(request, wrapped);
this.request = request;
}
@Override
public void write(boolean last, ByteBuffer content, Callback callback) {
if (request.refused != null && !isCommitted() && getStatus() != HttpStatus.REQUEST_TIMEOUT_408) {
super.setStatus(HttpStatus.REQUEST_TIMEOUT_408);
}
super.write(last, content, callback);
}
@Override
public void setStatus(int code) {
super.setStatus(request.refused != null && code >= 400 && code != HttpStatus.REQUEST_TIMEOUT_408
&& code < 500 ? HttpStatus.REQUEST_TIMEOUT_408 : code);
}
}
/** The request whose body reads are measured. Reads of one request are serial, as Jetty's demand model makes them. */
private static final class RateCheckedRequest extends Request.Wrapper {
private final long bytesPerSecond;
private final long creditCap;
private long received;
private long waitedNanos;
private long waitingSince = -1;
/** Bytes received minus the rate times the time waited, capped at {@link #creditCap}; negative = too slow. */
private long credit;
private Content.Chunk refused;
RateCheckedRequest(Request wrapped, long bytesPerSecond, long creditSeconds) {
super(wrapped);
this.bytesPerSecond = bytesPerSecond;
this.creditCap = bytesPerSecond * creditSeconds;
}
@Override
public Content.Chunk read() {
if (refused != null) {
return refused;
}
Content.Chunk chunk = super.read();
long now = System.nanoTime();
if (chunk == null) {
if (waitingSince < 0) {
waitingSince = now;
}
return null;
}
long waited = 0;
if (waitingSince >= 0) {
waited = now - waitingSince;
waitedNanos += waited;
waitingSince = -1;
}
if (Content.Chunk.isFailure(chunk)) {
return chunk;
}
int bytes = chunk.remaining();
received += bytes;
// Each byte earns credit and each second of waiting costs the rate's worth; earning is capped, so a body
// sent fast at first cannot bank more than CREDIT_SECONDS of waiting for a drip later.
credit = Math.min(creditCap, credit + bytes - bytesPerSecond * (waited / 1_000_000) / 1000);
boolean complete = chunk.isLast() || (getLength() >= 0 && received >= getLength());
if (!complete && waitedNanos >= GRACE_NANOS && credit < 0) {
chunk.release();
refused = Content.Chunk.from(new HttpException.RuntimeException(HttpStatus.REQUEST_TIMEOUT_408,
"request body slower than " + bytesPerSecond + " bytes/s"), true);
return refused;
}
return chunk;
}
}
}
@@ -16,15 +16,22 @@ import org.springframework.context.annotation.Configuration;
/**
* Keeps slow clients from holding request threads: a minimum rate for request bodies ({@code
* runway.http.min-request-data-rate}, bytes per second; Settings → Server settings → Request limits), applied to every
* connector Jetty has when the server is built.
* read of a request body by {@link RequestBodyRateHandler}, installed when the server is built.
*
* <p><b>Why.</b> A servlet reads a request body on a request thread and blocks while it waits. Jetty's idle timeout
* limits one stalled read, not the whole body, so a client that sends a byte inside every idle interval kept a thread
* for as long as it liked, and a few of them (with uploads allowed up to 256 MB) could take the pool. With a minimum
* rate Jetty answers {@code 408 Request Timeout} as soon as the body has arrived more slowly than the rate since its
* first byte; time the application spends before reading does not count, because the rate is measured on what has
* arrived. Measured on Jetty 12.1.8: a client sending one byte a second against 1 KiB/s was cut after about two
* seconds, and a server pausing three seconds before reading a body that arrived at once still answered {@code 200}.
* rate the request is answered {@code 408 Request Timeout} once the body arrives more slowly than the rate; time the
* application spends before reading does not count. Measured on Jetty 12.1.8 with Runway 1.1.1: form, multipart and
* stream bodies dripped at 20 bytes a second against 4 KiB/s were answered {@code 408} after two seconds, on both
* login pages and a plugin's form route, and a server pausing three seconds before reading a body that arrived at
* once still answered {@code 200}.
*
* <p><b>One check, under every read.</b> Jetty's own minimum rate is checked only where the body is read through
* {@code getInputStream()}; form parameters and multipart parts are parsed through Jetty's core request and escaped
* it (1.1.0 shipped with that gap: a dripped login form was held until the idle timeout). {@link
* RequestBodyRateHandler} wraps the core request under the server, so every read passes it, and Jetty's own check
* is turned off so that the two cannot race ({@link #apply}).
*
* <p><b>What it does not cover.</b> Slow header senders cost a connection, not a thread (Jetty parses headers without
* one); a proxy's connection cap is the limit there. A client that reads a response slowly is bounded by the
@@ -45,21 +52,34 @@ public class SlowClientConfig {
}
/**
* Sets the minimum request data rate on every HTTP configuration of {@code server}'s connectors.
* Installs the body-rate check on {@code server}: a {@link RequestBodyRateHandler} directly under the server, and
* Jetty's own minimum request data rate set to {@code 0} on every HTTP configuration of its connectors.
*
* <p>Jetty's own check covers {@code getInputStream()} only, and fires above this handler, so the two raced on
* the stream path: when Jetty's won, the failure escaped as an {@code IOException} that the application chain
* turned into an empty {@code 200} (measured on a plugin route that reads its form from the stream). One check,
* under every read, answers {@code 408} on every path. Boot has set the server's handler before its customizers
* run, and wraps the result in its own statistics handler afterwards.
*
* @param bytesPerSecond the rate; 0 turns the check off
* @return how many HTTP configurations were changed
* @return how many HTTP configurations had Jetty's own check set to 0
*/
static int apply(Server server, long bytesPerSecond) {
int changed = 0;
for (Connector connector : server.getConnectors()) {
for (ConnectionFactory factory : connector.getConnectionFactories()) {
if (factory instanceof HttpConfiguration.ConnectionFactory http) {
http.getHttpConfiguration().setMinRequestDataRate(bytesPerSecond);
http.getHttpConfiguration().setMinRequestDataRate(0);
changed++;
}
}
}
if (bytesPerSecond > 0 && server.getHandler() != null
&& !(server.getHandler() instanceof RequestBodyRateHandler)) {
RequestBodyRateHandler rate = new RequestBodyRateHandler(bytesPerSecond);
rate.setHandler(server.getHandler());
server.setHandler(rate);
}
if (bytesPerSecond > 0) {
log.info("request bodies slower than {} bytes/s are refused (runway.http.min-request-data-rate)",
bytesPerSecond);
@@ -320,10 +320,11 @@ runway:
trusted-cidrs:
- "127.0.0.1/32"
- "::1/128"
# How slowly a client may send a request body, in bytes per second, before Jetty answers 408 and frees the
# request thread (SlowClientConfig). Measured from the body's first byte on what has arrived, so a server that is
# slow to read is never blamed. 4096 is below any real connection; 0 turns the check off. Also on Settings ->
# Server settings -> Request limits.
# How slowly a client may send a request body (any: forms, uploads, raw), in bytes per second, before Runway
# answers 408 and frees the request thread (SlowClientConfig, RequestBodyRateHandler). Only time spent waiting for
# the client counts, so a server that is slow to read is never blamed, and a body that has arrived complete is never
# refused. 4096 is below any real connection; 0 turns the check off. Also on Settings -> Server settings -> Request
# limits.
http:
min-request-data-rate: 4096
# Stored-backup retention (app-level, not tenant-editable). After a site backup is written, its own
@@ -633,6 +633,15 @@ op.sites.hosts.hint=Comma-separated. Leave empty to make this site reachable onl
op.sites.base=Base URL
op.sites.base.hint=The origin every absolute link of the site is built on: canonical links, the sitemap, structured data, social cards. Leave it empty to use https:// and the first host. Set it when the site is served over http, on another port, or under another of its hosts (www). No path.
op.sites.base.row=Links: {0}
op.sites.hosts.short=Hosts
op.restore.review.title=Review how site {0} is reached
op.restore.review.hint=The restore applied the hosts and base URL saved in the backup. Check them, and correct them here if this installation reaches the site differently; saving does what Sites → Edit hosts does.
op.restore.review.noHosts=none: the site is reached only as the catch-all default site
op.restore.review.unreachable=none: no address reaches this site until you give it a host
op.restore.review.noBase=none: there is no host to build it from
op.restore.review.derived=not set, so {0} (https:// and the first host)
op.restore.review.kept.title=How the site is reached
op.restore.review.kept.hint=A restore made here keeps the site's hosts and base URL. Check them: only a platform administrator can change them, on the application console.
op.sites.edit=Edit
op.sites.edit.title=Edit site
op.sites.edit.locales=Available languages
@@ -1488,7 +1497,7 @@ op.ks.runway.csp.frame-ancestors.help=Which sites may show these pages in a fram
op.ks.runway.endpoints.max-form-bytes=Largest request before sign-in (bytes)
op.ks.runway.endpoints.max-form-bytes.help=The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).
op.ks.runway.http.min-request-data-rate=Slowest request body (bytes per second)
op.ks.runway.http.min-request-data-rate.help=A request body arriving more slowly is answered 408 Request Timeout, so a client sending a byte now and then cannot hold a request thread. Measured on what has arrived since the body's first byte. Default 4096; 0 turns the check off.
op.ks.runway.http.min-request-data-rate.help=A request body arriving more slowly is answered 408 Request Timeout: login and other forms, uploads and raw bodies alike, so a client sending a byte now and then cannot keep a request thread. Only time spent waiting for the client counts, and a body that has arrived complete is never refused. Sending part of a body fast earns at most 30 seconds of waiting. Default 4096; 0 turns the check off.
op.ks.runway.endpoints.max-body-bytes=Largest request to a plugin (bytes)
op.ks.runway.endpoints.max-body-bytes.help=The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).
op.ks.spring.servlet.multipart.max-file-size=Largest uploaded file
@@ -634,6 +634,15 @@ op.sites.hosts.hint=Separados por comas. Déjelo vacío para que el sitio solo s
op.sites.base=URL base
op.sites.base.hint=El origen sobre el que se construyen todos los enlaces absolutos del sitio: enlaces canónicos, el mapa del sitio, los datos estructurados y las tarjetas para redes sociales. Déjelo vacío para usar https:// y el primer host. Fíjelo cuando el sitio se sirva por http, en otro puerto o con otro de sus hosts (www). Sin ruta.
op.sites.base.row=Enlaces: {0}
op.sites.hosts.short=Hosts
op.restore.review.title=Revise cómo se llega al sitio {0}
op.restore.review.hint=La restauración aplicó los hosts y la URL base guardados en la copia. Revíselos y corríjalos aquí si esta instalación llega al sitio de otra forma; guardar hace lo mismo que Sitios → Editar hosts.
op.restore.review.noHosts=ninguno: al sitio solo se llega como sitio predeterminado (catch-all)
op.restore.review.unreachable=ninguno: ninguna dirección llega a este sitio hasta que le dé un host
op.restore.review.noBase=ninguna: no hay host con el que construirla
op.restore.review.derived=sin fijar, así que {0} (https:// y el primer host)
op.restore.review.kept.title=Cómo se llega al sitio
op.restore.review.kept.hint=Una restauración hecha aquí conserva los hosts y la URL base del sitio. Revíselos: solo un administrador de la plataforma puede cambiarlos, en la consola de la aplicación.
op.sites.edit=Editar
op.sites.edit.title=Editar sitio
op.sites.edit.locales=Idiomas disponibles
@@ -1489,7 +1498,7 @@ op.ks.runway.csp.frame-ancestors.help=Qué sitios pueden mostrar estas páginas
op.ks.runway.endpoints.max-form-bytes=Solicitud máxima sin sesión (bytes)
op.ks.runway.endpoints.max-form-bytes.help=Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB).
op.ks.runway.http.min-request-data-rate=Cuerpo de solicitud más lento (bytes por segundo)
op.ks.runway.http.min-request-data-rate.help=Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout, así que un cliente que envía un byte de vez en cuando no puede ocupar un hilo de solicitud. Se mide sobre lo recibido desde el primer byte del cuerpo. Por omisión 4096; 0 desactiva la comprobación.
op.ks.runway.http.min-request-data-rate.help=Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout: formularios (también el de inicio de sesión), subidas y cuerpos sin formato por igual, así que un cliente que envía un byte de vez en cuando no puede retener un hilo de solicitud. Solo cuenta el tiempo de espera por el cliente, y un cuerpo que ya llegó completo nunca se rechaza. Enviar rápido parte del cuerpo da como máximo 30 segundos de espera. Por omisión 4096; 0 desactiva la comprobación.
op.ks.runway.endpoints.max-body-bytes=Solicitud máxima a un complemento (bytes)
op.ks.runway.endpoints.max-body-bytes.help=Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB).
op.ks.spring.servlet.multipart.max-file-size=Archivo subido máximo
@@ -12,6 +12,20 @@
</div>
</div>
<div class="card mb-3 border-primary" id="bk-review">
<div class="card-header"><h3 class="card-title" id="bk-review-title">How the site is reached</h3></div>
<div class="card-body">
<p class="text-secondary" id="bk-review-hint">A restore made here keeps the site's hosts and base URL.
Check them; only a platform administrator can change them.</p>
<dl class="row mb-0">
<dt class="col-sm-2" id="bk-review-l-hosts">Hosts</dt>
<dd class="col-sm-10 font-monospace" id="bk-review-hosts">example.com</dd>
<dt class="col-sm-2" id="bk-review-l-base">Base URL</dt>
<dd class="col-sm-10 font-monospace mb-0" id="bk-review-base">https://example.com</dd>
</dl>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="card mb-3">
@@ -7,6 +7,15 @@
<attr sel="#bk-pretitle" th:text="#{op.realm.tenant}"/>
<attr sel="#bk-heading" th:text="#{op.backups.heading}"/>
<!-- After a restore (${reviewSite}): how the site is reached, read-only — a restore here keeps them. -->
<attr sel="#bk-review" th:if="${reviewSite != null}"/>
<attr sel="#bk-review-title" th:text="#{op.restore.review.kept.title}"/>
<attr sel="#bk-review-hint" th:text="#{op.restore.review.kept.hint}"/>
<attr sel="#bk-review-l-hosts" th:text="#{op.sites.hosts.short}"/>
<attr sel="#bk-review-hosts" th:text="${reviewSite == null or reviewSite.hosts().isEmpty()} ? (${reviewIsDefault} ? #{op.restore.review.noHosts} : #{op.restore.review.unreachable}) : ${#strings.listJoin(reviewSite.hosts(), ', ')}"/>
<attr sel="#bk-review-l-base" th:text="#{op.sites.base}"/>
<attr sel="#bk-review-base" th:text="${reviewSite?.baseUrl() != null} ? ${reviewSite.baseUrl()} : (${reviewSite == null or reviewSite.hosts().isEmpty()} ? #{op.restore.review.noBase} : #{op.restore.review.derived('https://' + ${reviewSite.hosts().get(0)})})"/>
<attr sel="#bk-l-make" th:text="#{op.backups.make}"/>
<attr sel="#bk-make-hint" th:text="#{op.backups.make.hint}"/>
<attr sel="#bk-download-now" th:if="${canDownloadFull}" th:text="#{op.backups.downloadNow}"/>
@@ -16,6 +16,38 @@
</div>
</div>
<div class="card mb-3 border-primary" id="ab-review">
<div class="card-header"><h3 class="card-title" id="ab-review-title">Review how the site is reached</h3></div>
<div class="card-body">
<p class="text-secondary" id="ab-review-hint">The restore applied the hosts and base URL saved in the
backup. Check them, and correct them here if this installation reaches the site differently.</p>
<dl class="row mb-3">
<dt class="col-sm-2" id="ab-review-l-hosts">Hosts</dt>
<dd class="col-sm-10 font-monospace" id="ab-review-hosts">example.com</dd>
<dt class="col-sm-2" id="ab-review-l-base">Base URL</dt>
<dd class="col-sm-10 font-monospace" id="ab-review-base">https://example.com</dd>
</dl>
<form id="ab-review-form" method="post" action="#">
<input id="ab-review-csrf" type="hidden" name="_csrf" value="">
<div class="row">
<div class="col-md-6 mb-2">
<label class="form-label" id="ab-review-l-hosts-input" for="ab-review-hosts-input">Hosts</label>
<input class="form-control" id="ab-review-hosts-input" name="hosts" autocomplete="off"
placeholder="example.com, www.example.com">
<small class="form-hint" id="ab-review-hosts-hint">Comma-separated.</small>
</div>
<div class="col-md-6 mb-2">
<label class="form-label" id="ab-review-l-base-input" for="ab-review-base-input">Base URL</label>
<input class="form-control" id="ab-review-base-input" name="baseUrl" type="url" maxlength="300"
autocomplete="off" spellcheck="false">
<small class="form-hint" id="ab-review-base-hint">The origin of the site's absolute links.</small>
</div>
</div>
<button type="submit" class="btn btn-primary" id="ab-review-save">Save hosts</button>
</form>
</div>
</div>
<div class="card mb-3">
<div class="card-header"><h3 class="card-title" id="cs-l">Create a site from a backup</h3></div>
<div class="card-body">
@@ -5,6 +5,27 @@
<attr sel="#ab-pretitle" th:text="#{op.realm.application}"/>
<attr sel="#ab-heading" th:text="#{op.appbackups.heading}"/>
<!-- After a restore or a site created from a backup (${reviewSite}): the site's hosts and base URL as they stand,
with the same editor as Sites -> Edit hosts (it posts there, so that route's checks and activity line apply).
Restoring here already required a platform administrator, who may edit any site's hosts. -->
<attr sel="#ab-review" th:if="${reviewSite != null}"/>
<attr sel="#ab-review-title" th:text="#{op.restore.review.title(${reviewSite?.id()})}"/>
<attr sel="#ab-review-hint" th:text="#{op.restore.review.hint}"/>
<attr sel="#ab-review-l-hosts" th:text="#{op.sites.hosts.short}"/>
<attr sel="#ab-review-hosts" th:text="${reviewSite == null or reviewSite.hosts().isEmpty()} ? (${reviewIsDefault} ? #{op.restore.review.noHosts} : #{op.restore.review.unreachable}) : ${#strings.listJoin(reviewSite.hosts(), ', ')}"/>
<attr sel="#ab-review-l-base" th:text="#{op.sites.base}"/>
<attr sel="#ab-review-base" th:text="${reviewSite?.baseUrl() != null} ? ${reviewSite.baseUrl()} : (${reviewSite == null or reviewSite.hosts().isEmpty()} ? #{op.restore.review.noBase} : #{op.restore.review.derived('https://' + ${reviewSite.hosts().get(0)})})"/>
<attr sel="#ab-review-form" th:attr="action='/__app/sites/' + ${reviewSite?.id()} + '/hosts'"/>
<attr sel="#ab-review-csrf"
th:attr="name=${_csrf != null ? _csrf.parameterName : '_csrf'},value=${_csrf != null ? _csrf.token : ''}"/>
<attr sel="#ab-review-l-hosts-input" th:text="#{op.sites.hosts}"/>
<attr sel="#ab-review-hosts-input" th:attr="value=${reviewSite == null ? '' : #strings.listJoin(reviewSite.hosts(), ', ')}"/>
<attr sel="#ab-review-hosts-hint" th:text="#{op.sites.hosts.hint}"/>
<attr sel="#ab-review-l-base-input" th:text="#{op.sites.base}"/>
<attr sel="#ab-review-base-input" th:attr="value=${reviewSite?.baseUrl()},placeholder=${reviewSite == null or reviewSite.hosts().isEmpty() ? '' : 'https://' + reviewSite.hosts().get(0)}"/>
<attr sel="#ab-review-base-hint" th:text="#{op.sites.base.hint}"/>
<attr sel="#ab-review-save" th:text="#{op.sites.hosts.save}"/>
<attr sel="#cs-l" th:text="#{op.appbackups.create}"/>
<attr sel="#cs-hint" th:text="#{op.appbackups.create.hint}"/>
<attr sel="#cs-csrf"