[release] version 0.5.2
This commit is contained in:
parent
913e88896b
commit
4e70cdfc60
|
@ -67,6 +67,7 @@ const ConfigManagement = () => {
|
|||
HTTPPort: config.HTTPConfig.HTTPPort,
|
||||
HTTPSPort: config.HTTPConfig.HTTPSPort,
|
||||
SSLEmail: config.HTTPConfig.SSLEmail,
|
||||
UseWildcardCertificate: config.HTTPConfig.UseWildcardCertificate,
|
||||
HTTPSCertificateMode: config.HTTPConfig.HTTPSCertificateMode,
|
||||
DNSChallengeProvider: config.HTTPConfig.DNSChallengeProvider,
|
||||
|
||||
|
@ -99,6 +100,7 @@ const ConfigManagement = () => {
|
|||
HTTPPort: values.HTTPPort,
|
||||
HTTPSPort: values.HTTPSPort,
|
||||
SSLEmail: values.SSLEmail,
|
||||
UseWildcardCertificate: values.UseWildcardCertificate,
|
||||
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
||||
DNSChallengeProvider: values.DNSChallengeProvider,
|
||||
},
|
||||
|
@ -381,8 +383,13 @@ const ConfigManagement = () => {
|
|||
]}
|
||||
/>
|
||||
|
||||
{
|
||||
formik.values.HTTPSCertificateMode === "LETSENCRYPT" && (
|
||||
<CosmosCheckbox
|
||||
label={"Use Wildcard Certificate for *." + formik.values.Hostname}
|
||||
name="UseWildcardCertificate"
|
||||
formik={formik}
|
||||
/>
|
||||
|
||||
{formik.values.HTTPSCertificateMode === "LETSENCRYPT" && (
|
||||
<CosmosInputText
|
||||
name="SSLEmail"
|
||||
label="Email address for Let's Encrypt"
|
||||
|
|
|
@ -14,7 +14,7 @@ import { useEffect, useState } from 'react';
|
|||
|
||||
import * as API from '../../api';
|
||||
import { Formik } from 'formik';
|
||||
import { CosmosInputPassword, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts';
|
||||
import { CosmosCheckbox, CosmosInputPassword, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts';
|
||||
import AnimateButton from '../../components/@extended/AnimateButton';
|
||||
import { Box } from '@mui/system';
|
||||
// ================================|| LOGIN ||================================ //
|
||||
|
@ -224,7 +224,8 @@ const NewInstall = () => {
|
|||
<div>
|
||||
<Formik
|
||||
initialValues={{
|
||||
HTTPSCertificateMode: "LETSENCRYPT"
|
||||
HTTPSCertificateMode: "LETSENCRYPT",
|
||||
UseWildcardCertificate: false,
|
||||
}}
|
||||
validationSchema={Yup.object().shape({
|
||||
SSLEmail: Yup.string().when('HTTPSCertificateMode', {
|
||||
|
@ -253,6 +254,7 @@ const NewInstall = () => {
|
|||
step: "3",
|
||||
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
||||
SSLEmail: values.SSLEmail,
|
||||
UseWildcardCertificate: values.UseWildcardCertificate,
|
||||
TLSKey: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSKey : '',
|
||||
TLSCert: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSCert : '',
|
||||
Hostname: values.Hostname,
|
||||
|
@ -321,11 +323,19 @@ const NewInstall = () => {
|
|||
formik={formik}
|
||||
/>
|
||||
|
||||
|
||||
<CosmosCheckbox
|
||||
label={"Use Wildcard Certificate for *." + formik.values.Hostname}
|
||||
name="UseWildcardCertificate"
|
||||
formik={formik}
|
||||
/>
|
||||
|
||||
{formik.errors.submit && (
|
||||
<Grid item xs={12}>
|
||||
<FormHelperText error>{formik.errors.submit}</FormHelperText>
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
<AnimateButton>
|
||||
<Button
|
||||
type="submit"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cosmos-server",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"description": "",
|
||||
"main": "test-server.js",
|
||||
"bugs": {
|
||||
|
|
|
@ -38,7 +38,7 @@ func startHTTPSServer(router *mux.Router, tlsCert string, tlsKey string) {
|
|||
|
||||
cfg := simplecert.Default
|
||||
|
||||
cfg.Domains = utils.GetAllHostnames()
|
||||
cfg.Domains = utils.GetAllHostnames(false, false)
|
||||
cfg.CacheDir = "/config/certificates"
|
||||
cfg.SSLEmail = config.HTTPConfig.SSLEmail
|
||||
cfg.HTTPAddress = "0.0.0.0:"+serverPortHTTP
|
||||
|
@ -153,7 +153,7 @@ func StartServer() {
|
|||
var tlsCert = HTTPConfig.TLSCert
|
||||
var tlsKey= HTTPConfig.TLSKey
|
||||
|
||||
domains := utils.GetAllHostnames()
|
||||
domains := utils.GetAllHostnames(true, true)
|
||||
oldDomains := baseMainConfig.HTTPConfig.TLSKeyHostsCached
|
||||
|
||||
NeedsRefresh := (tlsCert == "" || tlsKey == "") || !utils.StringArrayEquals(domains, oldDomains)
|
||||
|
|
|
@ -32,6 +32,7 @@ type NewInstallJSON struct {
|
|||
Hostname string `json:"hostname"`
|
||||
Step string `json:"step"`
|
||||
SSLEmail string `json:"sslEmail",validate:"omitempty,email"`
|
||||
UseWildcardCertificate bool `json:"useWildcardCertificate",validate:"omitempty"`
|
||||
}
|
||||
|
||||
type AdminJSON struct {
|
||||
|
@ -106,6 +107,7 @@ func NewInstallRoute(w http.ResponseWriter, req *http.Request) {
|
|||
// HTTPS Certificate Mode & Certs & Let's Encrypt
|
||||
newConfig.HTTPConfig.HTTPSCertificateMode = request.HTTPSCertificateMode
|
||||
newConfig.HTTPConfig.SSLEmail = request.SSLEmail
|
||||
newConfig.HTTPConfig.UseWildcardCertificate = request.UseWildcardCertificate
|
||||
newConfig.HTTPConfig.TLSCert = request.TLSCert
|
||||
newConfig.HTTPConfig.TLSKey = request.TLSKey
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ func EnsureHostname(next http.Handler) http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
hostnames := GetAllHostnames()
|
||||
hostnames := GetAllHostnames(false, false)
|
||||
|
||||
reqHostNoPort := strings.Split(r.Host, ":")[0]
|
||||
|
||||
|
@ -212,7 +212,7 @@ func IsValidHostname(hostname string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
hostnames := GetAllHostnames()
|
||||
hostnames := GetAllHostnames(false, false)
|
||||
|
||||
reqHostNoPort := strings.Split(hostname, ":")[0]
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ type HTTPConfig struct {
|
|||
ProxyConfig ProxyConfig
|
||||
Hostname string `validate:"required,excludesall=0x2C/ "`
|
||||
SSLEmail string `validate:"omitempty,email"`
|
||||
UseWildcardCertificate bool
|
||||
AcceptAllInsecureHostname bool
|
||||
}
|
||||
|
||||
|
|
|
@ -294,16 +294,29 @@ func RestartServer() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
func GetAllHostnames() []string {
|
||||
hostnames := []string{
|
||||
GetMainConfig().HTTPConfig.Hostname,
|
||||
func GetAllHostnames(applyWildCard bool, removePorts bool) []string {
|
||||
mainHostname := GetMainConfig().HTTPConfig.Hostname
|
||||
|
||||
if applyWildCard && MainConfig.HTTPConfig.UseWildcardCertificate {
|
||||
mainHostname = "*." + mainHostname
|
||||
Log("Using wildcard certificate for " + mainHostname + " and all subdomains.")
|
||||
}
|
||||
|
||||
hostnames := []string{
|
||||
mainHostname,
|
||||
}
|
||||
|
||||
proxies := GetMainConfig().HTTPConfig.ProxyConfig.Routes
|
||||
for _, proxy := range proxies {
|
||||
if proxy.UseHost && proxy.Host != "" && strings.Contains(proxy.Host, ".") && !strings.Contains(proxy.Host, ",") && !strings.Contains(proxy.Host, " ") {
|
||||
hostnames = append(hostnames, proxy.Host)
|
||||
if removePorts {
|
||||
hostnames = append(hostnames, strings.Split(proxy.Host, ":")[0])
|
||||
} else {
|
||||
hostnames = append(hostnames, proxy.Host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove doubles
|
||||
seen := make(map[string]bool)
|
||||
uniqueHostnames := []string{}
|
||||
|
@ -313,6 +326,20 @@ func GetAllHostnames() []string {
|
|||
uniqueHostnames = append(uniqueHostnames, hostname)
|
||||
}
|
||||
}
|
||||
|
||||
if applyWildCard && MainConfig.HTTPConfig.UseWildcardCertificate {
|
||||
filteredHostnames := []string{
|
||||
mainHostname,
|
||||
}
|
||||
|
||||
for _, hostname := range uniqueHostnames {
|
||||
if hostname != mainHostname && !strings.HasSuffix(hostname, mainHostname[1:]) {
|
||||
filteredHostnames = append(filteredHostnames, hostname)
|
||||
}
|
||||
}
|
||||
uniqueHostnames = filteredHostnames
|
||||
}
|
||||
|
||||
Debug("Hostnames are " + strings.Join(uniqueHostnames, ", "))
|
||||
return uniqueHostnames
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue