feature(cmd): implémenter UI API TLS skip verify #62

Merged
vlbeaudoin merged 3 commits from vlbeaudoin/feature/ui-allow-selfsigned-api-tls into main 2024-09-03 16:44:19 -04:00 AGit
3 changed files with 38 additions and 6 deletions

10
cmd.go
View file

@ -3,6 +3,7 @@ package main
import (
"context"
"crypto/subtle"
"crypto/tls"
"fmt"
"html/template"
"log"
@ -181,8 +182,15 @@ var uiCmd = &cobra.Command{
}
// API Client
var httpClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: cfg.Server.UI.API.TLS.SkipVerify,
},
},
}
apiClient := APIClient{voki.New(
http.DefaultClient,
httpClient,
cfg.Server.UI.API.Host,
cfg.Server.UI.API.Key,
cfg.Server.UI.API.Port,

View file

@ -45,6 +45,9 @@ type Config struct {
Key string `yaml:"key"`
Port int `yaml:"port"`
Protocol string `yaml:"protocol"`
TLS struct {
SkipVerify bool `yaml:"skipverify"`
} `yaml:"tls"`
} `yaml:"api"`
Host string `yaml:"host"`
Password string `yaml:"password"`
@ -367,6 +370,19 @@ func init() {
log.Fatal(err)
}
// server.ui.api.tls.skipverify
uiCmd.PersistentFlags().Bool(
"server-ui-api-tls-skipverify",
false,
"Skip API server TLS certificate verification",
)
if err := viper.BindPFlag(
"server.ui.api.tls.skipverify",
uiCmd.PersistentFlags().Lookup("server-ui-api-tls-skipverify"),
); err != nil {
log.Fatal(err)
}
// server.ui.host
uiCmd.PersistentFlags().String(
"server-ui-host",

View file

@ -3,9 +3,9 @@ services:
db:
image: 'docker.io/library/postgres:16'
environment:
POSTGRES_DATABASE: "${BOTTIN_SERVER_API_DB_DATABASE}"
POSTGRES_PASSWORD: "${BOTTIN_SERVER_API_DB_PASSWORD}"
POSTGRES_USER: "${BOTTIN_SERVER_API_DB_USER}"
POSTGRES_DATABASE: "${BOTTIN_SERVER_API_DB_DATABASE:-bottin}"
POSTGRES_PASSWORD: "${BOTTIN_SERVER_API_DB_PASSWORD:-bottin}"
POSTGRES_USER: "${BOTTIN_SERVER_API_DB_USER:-bottin}"
volumes:
- 'db-data:/var/lib/postgresql/data'
restart: 'unless-stopped'
@ -15,7 +15,13 @@ services:
- db
build: .
image: 'git.agecem.com/agecem/bottin:latest'
env_file: '.env'
env:
BOTTIN_SERVER_API_DB_DATABASE: "${BOTTIN_SERVER_API_DB_DATABASE:-bottin}"
BOTTIN_SERVER_API_DB_HOST: "${BOTTIN_SERVER_API_DB_HOST:-db}"
BOTTIN_SERVER_API_DB_PASSWORD: "${BOTTIN_SERVER_API_DB_PASSWORD:-bottin}"
BOTTIN_SERVER_API_DB_USER: "${BOTTIN_SERVER_API_DB_USER:-bottin}"
#BOTTIN_SERVER_API_HOST: "${BOTTIN_SERVER_API_HOST:}"
#BOTTIN_SERVER_API_KEY: "${BOTTIN_SERVER_API_KEY
ports:
- '1312:1312'
volumes:
@ -28,7 +34,9 @@ services:
- api
build: .
image: 'git.agecem.com/agecem/bottin:latest'
env_file: '.env'
env:
BOTTIN_WEB_PASSWORD: "${BOTTIN_WEB_PASSWORD:-bottin}"
BOTTIN_WEB_USER: "${BOTTIN_WEB_USER:-bottin}"
ports:
- '2312:2312'
volumes: