Support requiring TLS for API access

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2026-03-06 16:24:06 -07:00
parent 779434331c
commit 395fa2c283
10 changed files with 30 additions and 16 deletions

View File

@@ -29,6 +29,7 @@ func (n IPNet) IPNet() net.IPNet {
type APIConf struct {
EnabledP *bool `yaml:"enabled,omitempty" default:"false"`
TLSEnabledP *bool `yaml:"tls,omitempty"`
AllowedNets []IPNet `yaml:"allowed subnets,omitempty" default:"[\"127.0.0.0/8\", \"::1/128\"]"`
}
@@ -49,3 +50,7 @@ func (conf *APIConf) Unmarshal(unmarshal func(interface{}) error) error {
func (conf APIConf) Enabled() bool {
return util.BoolP(conf.EnabledP)
}
func (conf APIConf) TLSEnabled() bool {
return util.BoolP(conf.TLSEnabledP)
}

View File

@@ -44,7 +44,7 @@ type WarewulfConf struct {
Port int `yaml:"port,omitempty" default:"9873"`
TlsPort int `yaml:"tls port,omitempty" default:"9874"`
SecureP *bool `yaml:"secure,omitempty" default:"true"`
EnableTLSP *bool `yaml:"tls,omitempty" default:"false"`
TLSEnabledP *bool `yaml:"tls,omitempty"`
UpdateInterval int `yaml:"update interval,omitempty" default:"60"`
AutobuildOverlaysP *bool `yaml:"autobuild overlays,omitempty" default:"true"`
EnableHostOverlayP *bool `yaml:"host overlay,omitempty" default:"true"`
@@ -56,8 +56,8 @@ func (conf WarewulfConf) Secure() bool {
return util.BoolP(conf.SecureP)
}
func (conf WarewulfConf) EnableTLS() bool {
return util.BoolP(conf.EnableTLSP)
func (conf WarewulfConf) TLSEnabled() bool {
return util.BoolP(conf.TLSEnabledP)
}
func (conf WarewulfConf) AutobuildOverlays() bool {

View File

@@ -17,7 +17,6 @@ func TestParse(t *testing.T) {
result: `
warewulf:
autobuild overlays: true
tls: false
grubboot: false
host overlay: true
port: 9873
@@ -65,7 +64,6 @@ network: 192.168.0.0
netmask: 255.255.255.0
warewulf:
autobuild overlays: true
tls: false
grubboot: false
host overlay: true
port: 9873
@@ -115,7 +113,6 @@ network: 192.168.0.0
netmask: 255.255.0.0
warewulf:
autobuild overlays: true
tls: false
grubboot: false
host overlay: true
port: 9873
@@ -162,7 +159,6 @@ ipaddr6: "2001:db8::1"
prefixlen6: "64"
warewulf:
autobuild overlays: true
tls: false
grubboot: false
host overlay: true
port: 9873
@@ -238,7 +234,6 @@ netmask: 255.255.255.0
network: 192.168.200.0
warewulf:
autobuild overlays: true
tls: false
grubboot: false
host overlay: true
port: 9873