[release] v0.5.4 - Add DNS challenge to installer

This commit is contained in:
Yann Stepienik 2023-05-18 19:30:26 +01:00
parent 84ceae0591
commit 5fb4ce9d99
4 changed files with 32 additions and 4 deletions

View file

@ -226,6 +226,7 @@ const NewInstall = () => {
initialValues={{
HTTPSCertificateMode: "LETSENCRYPT",
UseWildcardCertificate: false,
DNSChallengeProvider: '',
}}
validationSchema={Yup.object().shape({
SSLEmail: Yup.string().when('HTTPSCertificateMode', {
@ -258,6 +259,7 @@ const NewInstall = () => {
TLSKey: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSKey : '',
TLSCert: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSCert : '',
Hostname: values.Hostname,
DNSChallengeProvider: values.DNSChallengeProvider,
});
if(res.status == "OK") {
setStatus({ success: true });
@ -287,7 +289,8 @@ const NewInstall = () => {
<>
<Alert severity="warning">
If you are using Cloudflare, make sure the DNS record is <strong>NOT</strong> set to <b>Proxied</b> (you should not see the orange cloud but a grey one).
Otherwise Cloudflare will not allow Let's Encrypt to verify your domain.
Otherwise Cloudflare will not allow Let's Encrypt to verify your domain. <br />
Alternatively, you can also use the DNS challenge.
</Alert>
<CosmosInputText
name="SSLEmail"
@ -295,6 +298,19 @@ const NewInstall = () => {
placeholder={"email@domain.com"}
formik={formik}
/>
{formik.values.DNSChallengeProvider && formik.values.DNSChallengeProvider != '' && (
<Alert severity="info">
You have enabled the DNS challenge. Make sure you have set the environment variables for your DNS provider.
You can enable it now, but make sure you have set up your API tokens accordingly before attempting to access
Cosmos after this installer. See doc here: <a target="_blank" href="https://go-acme.github.io/lego/dns/">https://go-acme.github.io/lego/dns/</a>
</Alert>
)}
<CosmosInputText
label={"DNS Provider (only set if you want to use the DNS challenge)"}
name="DNSChallengeProvider"
placeholder={"provider"}
formik={formik}
/>
</>
)}
{formik.values.HTTPSCertificateMode === "PROVIDED" && (
@ -323,9 +339,15 @@ const NewInstall = () => {
formik={formik}
/>
{formik.values.HTTPSCertificateMode === "LETSENCRYPT" && formik.values.UseWildcardCertificate && (!formik.values.DNSChallengeProvider || formik.values.DNSChallengeProvider == '') && (
<Alert severity="error">
You have enabled wildcard certificates with Let's Encrypt. This only works if you use the DNS challenge!
Please edit the DNS Provider text input.
</Alert>
)}
<CosmosCheckbox
label={"Use Wildcard Certificate for *." + formik.values.Hostname}
label={"Use Wildcard Certificate for *." + (formik.values.Hostname || "")}
name="UseWildcardCertificate"
formik={formik}
/>

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.5.3",
"version": "0.5.4",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -33,6 +33,7 @@ type NewInstallJSON struct {
Step string `json:"step"`
SSLEmail string `json:"sslEmail",validate:"omitempty,email"`
UseWildcardCertificate bool `json:"useWildcardCertificate",validate:"omitempty"`
DNSChallengeProvider string `json:"dnsChallengeProvider",validate:"omitempty"`
}
type AdminJSON struct {
@ -108,6 +109,7 @@ func NewInstallRoute(w http.ResponseWriter, req *http.Request) {
newConfig.HTTPConfig.HTTPSCertificateMode = request.HTTPSCertificateMode
newConfig.HTTPConfig.SSLEmail = request.SSLEmail
newConfig.HTTPConfig.UseWildcardCertificate = request.UseWildcardCertificate
newConfig.HTTPConfig.DNSChallengeProvider = request.DNSChallengeProvider
newConfig.HTTPConfig.TLSCert = request.TLSCert
newConfig.HTTPConfig.TLSKey = request.TLSKey

View file

@ -169,7 +169,7 @@ func ReadConfigFromFile() Config {
return config
}
func LoadBaseMainConfig(config Config){
func LoadBaseMainConfig(config Config) {
BaseMainConfig = config
MainConfig = config
@ -211,6 +211,10 @@ func LoadBaseMainConfig(config Config){
if os.Getenv("COSMOS_SERVER_COUNTRY") != "" {
MainConfig.ServerCountry = os.Getenv("COSMOS_SERVER_COUNTRY")
}
// if BaseMainConfig.NewInstall {
// MainConfig.HTTPConfig.HTTPSCertificateMode = "DISABLED"
// }
}
func GetMainConfig() Config {