Merge pull request 'feature(cmd): implémenter UI API TLS skip verify' (#62) from vlbeaudoin/feature/ui-allow-selfsigned-api-tls into main

Reviewed-on: #62
This commit is contained in:
Victor Lacasse-Beaudoin 2024-09-03 16:44:18 -04:00
commit c0b8ceafa9
3 changed files with 38 additions and 6 deletions

10
cmd.go
View file

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

View file

@ -45,6 +45,9 @@ type Config struct {
Key string `yaml:"key"` Key string `yaml:"key"`
Port int `yaml:"port"` Port int `yaml:"port"`
Protocol string `yaml:"protocol"` Protocol string `yaml:"protocol"`
TLS struct {
SkipVerify bool `yaml:"skipverify"`
} `yaml:"tls"`
} `yaml:"api"` } `yaml:"api"`
Host string `yaml:"host"` Host string `yaml:"host"`
Password string `yaml:"password"` Password string `yaml:"password"`
@ -367,6 +370,19 @@ func init() {
log.Fatal(err) 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 // server.ui.host
uiCmd.PersistentFlags().String( uiCmd.PersistentFlags().String(
"server-ui-host", "server-ui-host",

View file

@ -3,9 +3,9 @@ services:
db: db:
image: 'docker.io/library/postgres:16' image: 'docker.io/library/postgres:16'
environment: environment:
POSTGRES_DATABASE: "${BOTTIN_SERVER_API_DB_DATABASE}" POSTGRES_DATABASE: "${BOTTIN_SERVER_API_DB_DATABASE:-bottin}"
POSTGRES_PASSWORD: "${BOTTIN_SERVER_API_DB_PASSWORD}" POSTGRES_PASSWORD: "${BOTTIN_SERVER_API_DB_PASSWORD:-bottin}"
POSTGRES_USER: "${BOTTIN_SERVER_API_DB_USER}" POSTGRES_USER: "${BOTTIN_SERVER_API_DB_USER:-bottin}"
volumes: volumes:
- 'db-data:/var/lib/postgresql/data' - 'db-data:/var/lib/postgresql/data'
restart: 'unless-stopped' restart: 'unless-stopped'
@ -15,7 +15,13 @@ services:
- db - db
build: . build: .
image: 'git.agecem.com/agecem/bottin:latest' 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: ports:
- '1312:1312' - '1312:1312'
volumes: volumes:
@ -28,7 +34,9 @@ services:
- api - api
build: . build: .
image: 'git.agecem.com/agecem/bottin:latest' 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: ports:
- '2312:2312' - '2312:2312'
volumes: volumes: