feat: trocar configurações de certificado
Agora a emissão e renovação de certificado é automática.
This commit is contained in:
+31
-46
@@ -3,7 +3,6 @@ package tui
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"charm.land/bubbles/v2/spinner"
|
||||
@@ -31,6 +30,7 @@ type Model struct {
|
||||
|
||||
loginForm FormStep
|
||||
wireguardForm FormStep
|
||||
appForm FormStep
|
||||
serverForm FormStep
|
||||
dbForm FormStep
|
||||
certForm FormStep
|
||||
@@ -50,11 +50,12 @@ type DockerLoginData struct {
|
||||
}
|
||||
|
||||
type ConfigValues struct {
|
||||
Login map[string]string
|
||||
Wireguard map[string]string
|
||||
Server map[string]string
|
||||
Database map[string]string
|
||||
Cert map[string]string
|
||||
Login map[string]string
|
||||
Wireguard map[string]string
|
||||
Server map[string]string
|
||||
Database map[string]string
|
||||
Cert map[string]string
|
||||
Application map[string]string
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
@@ -70,12 +71,12 @@ type AppConfig struct {
|
||||
MinConns int64 `toml:"min_conns"`
|
||||
} `toml:"database"`
|
||||
Certificates struct {
|
||||
DirPath string `toml:"mapped_dir"`
|
||||
CertName string `toml:"cert_path"`
|
||||
KeyName string `toml:"key_path"`
|
||||
CAName string `toml:"ca_path"`
|
||||
ServerName string `toml:"server_name"`
|
||||
DirPath string `toml:"mapped_dir"`
|
||||
} `toml:"certificate"`
|
||||
Application struct {
|
||||
CentralServerURL string `toml:"central_server_url"`
|
||||
EnrollmentToken string `toml:"enrollment_token"`
|
||||
} `toml:"application"`
|
||||
}
|
||||
|
||||
func loadConfig() AppConfig {
|
||||
@@ -91,10 +92,8 @@ func loadConfig() AppConfig {
|
||||
config.Database.MinConns = 2
|
||||
|
||||
config.Certificates.DirPath = "/caminho/para/diretorio"
|
||||
config.Certificates.CertName = "certificado.crt"
|
||||
config.Certificates.KeyName = "chave.key"
|
||||
config.Certificates.CAName = "chaveCA.crt"
|
||||
config.Certificates.ServerName = "client"
|
||||
|
||||
config.Application.CentralServerURL = "https://servidor:8443"
|
||||
|
||||
_, err := os.Stat("config.toml")
|
||||
if err == nil {
|
||||
@@ -103,12 +102,6 @@ func loadConfig() AppConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
config.Certificates.CertName = filepath.Base(config.Certificates.CertName)
|
||||
config.Certificates.KeyName = filepath.Base(config.Certificates.KeyName)
|
||||
config.Certificates.CAName = filepath.Base(config.Certificates.CAName)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
@@ -231,37 +224,29 @@ func InitialModel() Model {
|
||||
Type: FieldTypeNumber,
|
||||
},
|
||||
}),
|
||||
certForm: NewFormStep("Certificado", []FormField{
|
||||
appForm: NewFormStep("Aplicação", []FormField{
|
||||
{
|
||||
Id: "cert_dir_path",
|
||||
Label: "Caminho para o diretório dos certificados",
|
||||
Placeholder: "/caminho/para/diretorio",
|
||||
Default: cfg.Certificates.DirPath,
|
||||
Id: "central_server_url",
|
||||
Label: "URL do Servidor Central",
|
||||
Placeholder: "https://servidor:8443",
|
||||
Default: cfg.Application.CentralServerURL,
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
{
|
||||
Id: "cert_name",
|
||||
Label: "Nome do arquivo do certificado",
|
||||
Default: cfg.Certificates.CertName,
|
||||
Type: FieldTypeText,
|
||||
Id: "enrollment_token",
|
||||
Label: "Token de Inscrição",
|
||||
Placeholder: "token gerado no painel web",
|
||||
Default: cfg.Application.EnrollmentToken,
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
}),
|
||||
certForm: NewFormStep("Certificado", []FormField{
|
||||
{
|
||||
Id: "key_name",
|
||||
Label: "Nome do arquivo da chave",
|
||||
Default: cfg.Certificates.KeyName,
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
{
|
||||
Id: "ca_name",
|
||||
Label: "Nome do arquivo da autoridade certificadora",
|
||||
Default: cfg.Certificates.CAName,
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
{
|
||||
Id: "server_name",
|
||||
Label: "Nome do servidor",
|
||||
Default: cfg.Certificates.ServerName,
|
||||
Type: FieldTypeText,
|
||||
Id: "cert_dir_path",
|
||||
Label: "Diretório para armazenar certificados",
|
||||
Placeholder: "/caminho/para/diretorio",
|
||||
Default: cfg.Certificates.DirPath,
|
||||
Type: FieldTypeText,
|
||||
},
|
||||
}),
|
||||
spinner: s,
|
||||
|
||||
Reference in New Issue
Block a user