From dba97aca00f82543e38f7511b20f1f5229ca664a Mon Sep 17 00:00:00 2001 From: Yann Stepienik Date: Thu, 4 May 2023 18:15:28 +0100 Subject: [PATCH] [release] v0.3.5 Let's Encrypt improvements --- client/src/pages/config/users/configman.jsx | 2 ++ .../src/pages/config/users/formShortcuts.jsx | 3 ++- client/src/pages/newInstall/newInstall.jsx | 22 ++++++++++++++++++- client/src/utils/routes.jsx | 2 +- package.json | 2 +- src/httpServer.go | 2 ++ 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/client/src/pages/config/users/configman.jsx b/client/src/pages/config/users/configman.jsx index e0daf25..2ea4d0e 100644 --- a/client/src/pages/config/users/configman.jsx +++ b/client/src/pages/config/users/configman.jsx @@ -165,6 +165,7 @@ const ConfigManagement = () => { { } -export const CosmosInputPassword = ({ name, noStrength, type, placeholder, onChange, label, formik }) => { +export const CosmosInputPassword = ({ name, noStrength, type, placeholder, autoComplete, onChange, label, formik }) => { const [level, setLevel] = React.useState(); const [showPassword, setShowPassword] = React.useState(false); const handleClickShowPassword = () => { @@ -80,6 +80,7 @@ export const CosmosInputPassword = ({ name, noStrength, type, placeholder, onCha type={showPassword ? 'text' : 'password'} value={formik.values[name]} name={name} + autoComplete={autoComplete} onBlur={formik.handleBlur} onChange={(e) => { changePassword(e.target.value); diff --git a/client/src/pages/newInstall/newInstall.jsx b/client/src/pages/newInstall/newInstall.jsx index 243e881..330f585 100644 --- a/client/src/pages/newInstall/newInstall.jsx +++ b/client/src/pages/newInstall/newInstall.jsx @@ -214,6 +214,26 @@ const NewInstall = () => { initialValues={{ HTTPSCertificateMode: "LETSENCRYPT" }} + validationSchema={Yup.object().shape({ + SSLEmail: Yup.string().when('HTTPSCertificateMode', { + is: "LETSENCRYPT", + then: Yup.string().email().required(), + otherwise: Yup.string().email(), + }), + TLSKey: Yup.string().when('HTTPSCertificateMode', { + is: "PROVIDED", + then: Yup.string().required(), + }), + TLSCert: Yup.string().when('HTTPSCertificateMode', { + is: "PROVIDED", + then: Yup.string().required(), + }), + Hostname: Yup.string().when('HTTPSCertificateMode', { + is: "LETSENCRYPT", + then: Yup.string().required().matches(/^((?!localhost|\d+\.\d+\.\d+\.\d+)[a-zA-Z0-9\-]{1,63}\.)+[a-zA-Z]{2,63}$/, 'Let\'s Encrypt only accepts domain names'), + otherwise: Yup.string().required() + }), + })} onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => { try { setSubmitting(true); @@ -229,7 +249,7 @@ const NewInstall = () => { setStatus({ success: true }); } catch (error) { setStatus({ success: false }); - setErrors({ submit: error.message }); + setErrors({ submit: "Please check you have filled all the inputs properly" }); setSubmitting(false); } }}> diff --git a/client/src/utils/routes.jsx b/client/src/utils/routes.jsx index 5952991..c6870dd 100644 --- a/client/src/utils/routes.jsx +++ b/client/src/utils/routes.jsx @@ -75,7 +75,7 @@ export const ValidateRouteSchema = Yup.object().shape({ Host: Yup.string().when('UseHost', { is: true, then: Yup.string().required('Host is required') - .matches(/[\.|\:]/, 'Host must be full domain ([sub.]domain.com) or an IP') + .matches(/[\.|\:]/, 'Host must be full domain ([sub.]domain.com) or an IP (IPs won\'t work with Let\'s Encrypt!)') }), PathPrefix: Yup.string().when('UsePathPrefix', { diff --git a/package.json b/package.json index 0731146..277c97f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.3.4", + "version": "0.3.5", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/httpServer.go b/src/httpServer.go index 0cbe7f5..68e1595 100644 --- a/src/httpServer.go +++ b/src/httpServer.go @@ -60,6 +60,8 @@ func startHTTPSServer(router *mux.Router, tlsCert string, tlsKey string) { if errSimCert != nil { // Temporary before we have a better way to handle this utils.Error("simplecert init failed, HTTPS wont renew", errSimCert) + startHTTPServer(router) + return } }