feature: HTTPS is always on, for wan.local_fqdn or, without it, the host name and its mDNS name, optionally also for the server's addresses, and the redirect to HTTPS covers the status page by name.
Release / release (push) Successful in 23s
Release / release (push) Successful in 23s
This commit is contained in:
1 parent
7efacfa3bb
commit
64c3ae4c36
18 files changed
+317
-187
No files matched your search
@@ -1,14 +1,15 @@
|
||||
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, TextField, Typography } from '@mui/material'
|
||||
import { Alert, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Stack, TextField, Typography } from '@mui/material'
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { HTTPS_CERTIFICATES, type HttpsCertificateSource, type HttpsChange, type HttpsSettings } from './api.ts'
|
||||
import { CERTIFICATE_LABELS } from './https.ts'
|
||||
|
||||
/**
|
||||
* A dialog that edits where the certificate of the server's FQDN comes from, https.certificate: the ACME CA of
|
||||
* A dialog that edits where the certificate of the server's HTTPS names comes from, https.certificate: the ACME CA of
|
||||
* AcmeSettingsDialog, a self-signed certificate valid for https.self_signed_days, the Servers Issuing CA, or another
|
||||
* CA's certificate, imported on the Server tab of the Certificates page; self-signed is selected while the first setup
|
||||
* has not chosen one. onSave sends the source and the validity
|
||||
* only; the dialog closes when it succeeds and shows the server's message when it fails.
|
||||
* has not chosen one. Without ACME, https.ip_sans adds the server's addresses to the self-signed certificate and the
|
||||
* Servers Issuing CA's. onSave sends the source, the validity and ip_sans only; the dialog closes when it succeeds and
|
||||
* shows the server's message when it fails.
|
||||
*/
|
||||
export default function HttpsSettingsDialog(props: {
|
||||
current: HttpsSettings
|
||||
@@ -17,6 +18,7 @@ export default function HttpsSettingsDialog(props: {
|
||||
}) {
|
||||
const [certificate, setCertificate] = useState<HttpsCertificateSource>(props.current.certificate || 'self-signed')
|
||||
const [days, setDays] = useState(String(props.current.self_signed_days))
|
||||
const [ipSans, setIpSans] = useState(props.current.ip_sans)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
@@ -31,7 +33,8 @@ export default function HttpsSettingsDialog(props: {
|
||||
setSaving(true)
|
||||
setError(null)
|
||||
try {
|
||||
await props.onSave(certificate === 'self-signed' ? { certificate, self_signed_days: Number(days) } : { certificate })
|
||||
await props.onSave(certificate === 'self-signed' ? { certificate, self_signed_days: Number(days), ip_sans: ipSans }
|
||||
: certificate === 'acme' ? { certificate } : { certificate, ip_sans: ipSans })
|
||||
} catch (caught) {
|
||||
setError((caught as Error).message)
|
||||
setSaving(false)
|
||||
@@ -62,6 +65,12 @@ export default function HttpsSettingsDialog(props: {
|
||||
onChange={(event) => setDays(event.target.value.trim())}
|
||||
/>
|
||||
)}
|
||||
{(certificate === 'self-signed' || certificate === 'ca') && (
|
||||
<FormControlLabel
|
||||
control={<Checkbox checked={ipSans} onChange={(event) => setIpSans(event.target.checked)} />}
|
||||
label="Also name the server's IP addresses, to reach it over HTTPS by address"
|
||||
/>
|
||||
)}
|
||||
{certificate === 'external' && (
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
The certificate is imported on this tab, from a CSR the server makes or as a PFX file. The server serves a self-signed certificate until then.
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
} from './api.ts'
|
||||
|
||||
/**
|
||||
* The Server tab of the Certificates page, the server's HTTPS from /config and /https/settings: whether HTTPS is on and
|
||||
* for which name, with a chip while the certificate has another source than ACME and a button that opens
|
||||
* The Server tab of the Certificates page, the server's HTTPS from /config and /https/settings: the names and addresses
|
||||
* HTTPS is served for, with a chip while the certificate has another source than ACME and a button that opens
|
||||
* HttpsSettingsDialog; the certificate of a source other than ACME, and, for one of another CA, Generate CSR, Import
|
||||
* certificate and Import PFX; the ACME CA with a chip while it is Let's Encrypt's staging environment and a button that
|
||||
* opens AcmeSettingsDialog; and Caddy, its version and the state of caddy.service. Until the first setup
|
||||
@@ -89,10 +89,9 @@ export default function ServerCertificatePanel() {
|
||||
}
|
||||
|
||||
const https = details?.configuration.https
|
||||
const fqdn = String(details?.configuration.wan?.local_fqdn ?? '')
|
||||
const httpsOn = https?.enabled === true
|
||||
const hosts = [...(details?.network.https_names ?? []), ...(details?.network.https_addresses ?? [])]
|
||||
const chosen = certificate !== null && certificate.source !== ''
|
||||
const other = httpsOn && certificate !== null && certificate.source !== 'acme'
|
||||
const other = certificate !== null && certificate.source !== 'acme'
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@@ -106,9 +105,9 @@ export default function ServerCertificatePanel() {
|
||||
rows={[
|
||||
['HTTPS', (
|
||||
<Stack key="https" direction="row" sx={{ alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>
|
||||
<span>{httpsOn ? (fqdn ? `on, for ${fqdn}` : 'on, but wan.local_fqdn is not set') : 'off'}</span>
|
||||
<span>{hosts.length > 0 ? `for ${hosts.join(', ')}` : 'on'}</span>
|
||||
{other && certificate.source !== '' && <Chip size="small" label={CERTIFICATE_LABELS[certificate.source]} color={certificate.served === certificate.source ? 'default' : 'warning'} />}
|
||||
{httpsOn && !chosen && <Typography variant="body2" color="text.secondary">certificate chosen by the next setup</Typography>}
|
||||
{!chosen && <Typography variant="body2" color="text.secondary">certificate chosen by the next setup</Typography>}
|
||||
<Tooltip title="HTTPS certificate">
|
||||
<IconButton size="small" aria-label="HTTPS certificate" onClick={() => void open('https')}>
|
||||
<Settings fontSize="small" />
|
||||
|
||||
+15
-11
@@ -23,9 +23,9 @@ const LAYOUT_KEY = 'linux-manager-ui.router-layout'
|
||||
* The server's state: its status, ok or degraded on the title bar of the Status panel, with the update information of
|
||||
* its packages (UpdatesNotice) at the top of that panel, its remote access clients, and from /config the status web
|
||||
* service; the state of each of its systemd services and of Caddy in the Services panel; the Addresses panel's links
|
||||
* to the status page, over HTTPS for wan.local_fqdn and over plain HTTP on the addresses web.listen names, and to the
|
||||
* Manager over HTTPS, and over plain HTTP on the addresses of its listen from /api/info while Caddy does not redirect
|
||||
* it, each address once, and the
|
||||
* to the status page and the Manager over HTTPS for the HTTPS names and addresses, and over plain HTTP: the status page
|
||||
* on the addresses web.listen names, the Manager on the addresses of its listen from /api/info only while the redirect
|
||||
* to HTTPS is off, and both by their HTTPS names only while it is off, each address once, and the
|
||||
* OpenID Provider's issuer and discovery URL, each with a copy icon, or off while it is disabled; its
|
||||
* backups with Run now, and its non-public details as tables and command output, with a panel per PostgreSQL
|
||||
* cluster: its settings from /config and its databases with their sizes from /postgresql. Read at once, then as the
|
||||
@@ -106,18 +106,22 @@ export default function ServerPanel() {
|
||||
const network = details?.network
|
||||
const web = details?.configuration.web
|
||||
const https = details?.configuration.https
|
||||
const fqdn = String(details?.configuration.wan?.local_fqdn ?? '')
|
||||
const httpsOn = https?.enabled === true
|
||||
// The hosts HTTPS is served for: its names, then its addresses while https.ip_sans is on.
|
||||
const httpsNames = network?.https_names ?? []
|
||||
const httpsHosts = [...httpsNames, ...(network?.https_addresses ?? [])].map((host) => (host.includes(':') ? `[${host}]` : host))
|
||||
const redirectOff = https?.disable_auto_redirect === true
|
||||
const httpsUrls = (port: unknown) => httpsHosts.map((host) => `https://${host}:${text(port)}`)
|
||||
// A request by name on a plain HTTP port is redirected to HTTPS unless the redirect is off.
|
||||
const plainNames = (port: unknown) => (redirectOff ? httpsNames.map((name) => `http://${name}:${text(port)}`) : [])
|
||||
// The plain HTTP URLs of a port on the addresses of the interfaces a listen setting names, each address once: without
|
||||
// the router the internal address is the external one.
|
||||
const plainUrls = (listen: string, port: unknown) => [...new Set([
|
||||
...(listen !== 'external' && network?.internal_address ? [network.internal_address] : []),
|
||||
...(listen !== 'internal' ? network?.external_addresses ?? [] : []),
|
||||
].map((address) => String(address).split('/')[0]))].map((address) => `http://${address}:${text(port)}`)
|
||||
const plain = web?.enabled === false ? [] : plainUrls(String(web?.listen ?? 'both'), web?.port)
|
||||
// The Manager over plain HTTP while Caddy does not redirect it to HTTPS.
|
||||
const managerPlain = manager && (!httpsOn || !fqdn || https?.disable_auto_redirect === true)
|
||||
? plainUrls(manager.listen, manager.port) : []
|
||||
// The status page stays on plain HTTP by address; the Manager only while the redirect is off.
|
||||
const plain = web?.enabled === false ? [] : [...plainNames(web?.port), ...plainUrls(String(web?.listen ?? 'both'), web?.port)]
|
||||
const managerPlain = manager && redirectOff ? [...plainNames(manager.port), ...plainUrls(manager.listen, manager.port)] : []
|
||||
|
||||
// The panels in their default order; a panel without data is left out, and keeps its place in the layout.
|
||||
const panels: BoardPanel[] = []
|
||||
@@ -258,8 +262,8 @@ export default function ServerPanel() {
|
||||
content: (
|
||||
<Pairs
|
||||
rows={[
|
||||
['Status page', <Links key="status" urls={[...(httpsOn && fqdn ? [`https://${fqdn}:${text(https?.web_port)}`] : []), ...plain]} />],
|
||||
['Ubuntu Linux Manager', <Links key="manager" urls={[...(httpsOn && fqdn ? [`https://${fqdn}:${text(https?.manager_port)}`] : []), ...managerPlain]} />],
|
||||
['Status page', <Links key="status" urls={[...(web?.enabled === false ? [] : httpsUrls(https?.web_port)), ...plain]} />],
|
||||
['Ubuntu Linux Manager', <Links key="manager" urls={[...httpsUrls(https?.manager_port), ...managerPlain]} />],
|
||||
...(details.oidc?.issuer
|
||||
? [
|
||||
['OpenID Provider', <Copyable key="issuer" value={details.oidc.issuer} label="issuer" />],
|
||||
|
||||
+10
-4
@@ -91,6 +91,10 @@ export type RouterDetails = {
|
||||
external_addresses?: string[]
|
||||
internal_address?: string
|
||||
internal_gateway?: string
|
||||
/** The names HTTPS is served for: wan.local_fqdn, or the host name and <host name>.local without it. */
|
||||
https_names?: string[]
|
||||
/** The addresses HTTPS is served for while https.ip_sans is on. */
|
||||
https_addresses?: string[]
|
||||
local_cidrs?: string[]
|
||||
/** Each site-to-site connection with the identities and subnets the server resolved for it. */
|
||||
site_to_site?: { name: string; local_identity: string; remote_identity: string; local_cidrs: string[]; remote_cidrs: string[] }[]
|
||||
@@ -502,10 +506,10 @@ export type AcmeProvider = (typeof ACME_PROVIDERS)[number]
|
||||
* the certificate source, '' until the first setup chooses it, and the ACME settings.
|
||||
*/
|
||||
export type HttpsSettings = {
|
||||
enabled: boolean
|
||||
email: string
|
||||
web_port: number
|
||||
manager_port: number
|
||||
ip_sans: boolean
|
||||
acme_staging: boolean
|
||||
certificate: HttpsCertificateSource | ''
|
||||
self_signed_days: number
|
||||
@@ -517,8 +521,8 @@ export type HttpsSettings = {
|
||||
}
|
||||
|
||||
/** The changes PUT /https/settings takes; a secret left out keeps its value. */
|
||||
export type HttpsChange = Partial<Pick<HttpsSettings, 'acme_staging' | 'certificate' | 'self_signed_days' | 'acme_provider' |
|
||||
'acme_url' | 'acme_eab_key_id'>> & { acme_eab_mac_key?: string; zerossl_api_key?: string }
|
||||
export type HttpsChange = Partial<Pick<HttpsSettings, 'acme_staging' | 'certificate' | 'self_signed_days' | 'ip_sans' |
|
||||
'acme_provider' | 'acme_url' | 'acme_eab_key_id'>> & { acme_eab_mac_key?: string; zerossl_api_key?: string }
|
||||
|
||||
/**
|
||||
* The server's HTTPS certificate: the chosen source, '' until the first setup chooses it, the one served (self-signed while the chosen one is not
|
||||
@@ -700,6 +704,8 @@ export const DETAILS_SHAPE = object({
|
||||
external_addresses: optional(list(string)),
|
||||
internal_address: optional(string),
|
||||
internal_gateway: optional(string),
|
||||
https_names: optional(list(string)),
|
||||
https_addresses: optional(list(string)),
|
||||
local_cidrs: optional(list(string)),
|
||||
site_to_site: optional(list(object({
|
||||
name: string,
|
||||
@@ -1154,10 +1160,10 @@ export const METRICS_SETTINGS_SHAPE = object({
|
||||
/** The shape of GET and PUT /https/settings; GET also has the certificate. */
|
||||
export const HTTPS_SETTINGS_SHAPE = object({
|
||||
settings: object({
|
||||
enabled: boolean,
|
||||
email: string,
|
||||
web_port: number,
|
||||
manager_port: number,
|
||||
ip_sans: boolean,
|
||||
acme_staging: boolean,
|
||||
certificate: string,
|
||||
self_signed_days: number,
|
||||
|
||||
Reference in new issue
Block a user