renamed BasicAuth to Auth

This commit is contained in:
2025-01-29 00:30:08 +09:00
parent 2fa5817e88
commit b7992a0bb7
4 changed files with 40 additions and 23 deletions

View File

@ -44,16 +44,17 @@ type ClientTLSConfig struct {
ServerName string `yaml:"server-name"`
}
type BasicAuthConfig struct {
type AuthConfig struct {
Enabled bool `yaml:"enabled"`
Realm string `yaml:"realm"`
Creds []string `yaml:"credentials"`
TokenTtl string `yaml:"token-ttl"`
}
type CTLServiceConfig struct {
Prefix string `yaml:"prefix"` // url prefix for control channel endpoints
Addrs []string `yaml:"addresses"`
BasicAuth BasicAuthConfig `yaml:"basic-auth"`
Auth AuthConfig `yaml:"auth"`
}
type PXYServiceConfig struct {
@ -345,8 +346,8 @@ func make_tls_client_config(cfg *ClientTLSConfig) (*tls.Config, error) {
}
// --------------------------------------------------------------------
func make_server_basic_auth_config(cfg *BasicAuthConfig) (*hodu.ServerBasicAuth, error) {
var config hodu.ServerBasicAuth
func make_server_basic_auth_config(cfg *AuthConfig) (*hodu.ServerAuthConfig, error) {
var config hodu.ServerAuthConfig
var cred string
var b []byte
var x []string
@ -354,7 +355,11 @@ func make_server_basic_auth_config(cfg *BasicAuthConfig) (*hodu.ServerBasicAuth,
config.Enabled = cfg.Enabled
config.Realm = cfg.Realm
config.Creds = make(hodu.ServerBasicAuthCredMap)
config.Creds = make(hodu.ServerAuthCredMap)
config.TokenTtl, err = hodu.ParseDurationString(cfg.TokenTtl)
if err != nil {
return nil, fmt.Errorf("invalid token ttl %s - %s", cred, err)
}
for _, cred = range cfg.Creds {
b, err = base64.StdEncoding.DecodeString(cred)

View File

@ -125,7 +125,7 @@ func server_main(ctl_addrs []string, rpc_addrs []string, pxy_addrs []string, wpx
if len(config.PxyAddrs) <= 0 { config.PxyAddrs = cfg.PXY.Service.Addrs }
if len(config.WpxAddrs) <= 0 { config.WpxAddrs = cfg.WPX.Service.Addrs }
config.CtlBasicAuth, err = make_server_basic_auth_config(&cfg.CTL.Service.BasicAuth)
config.CtlAuth, err = make_server_basic_auth_config(&cfg.CTL.Service.Auth)
if err != nil { return err }
config.CtlPrefix = cfg.CTL.Service.Prefix