diff --git a/config/config.go b/config/config.go index 4d77a9f50..e7f8b8259 100644 --- a/config/config.go +++ b/config/config.go @@ -288,6 +288,9 @@ func (conf *Config) BasicCheck() error { if err := conf.JSONRPC.BasicCheck(); err != nil { return err } + if err := conf.GRPC.BasicCheck(); err != nil { + return err + } return conf.HTTP.BasicCheck() } diff --git a/www/grpc/config.go b/www/grpc/config.go index a8b09e582..a413833c2 100644 --- a/www/grpc/config.go +++ b/www/grpc/config.go @@ -1,5 +1,7 @@ package grpc +import "github.com/pactus-project/pactus/util/htpasswd" + type Config struct { Enable bool `toml:"enable"` EnableWallet bool `toml:"enable_wallet"` @@ -23,3 +25,13 @@ func DefaultConfig() *Config { }, } } + +func (c *Config) BasicCheck() error { + if c.BasicAuth != "" { + if _, _, err := htpasswd.ExtractBasicAuth(c.BasicAuth); err != nil { + return err + } + } + + return nil +}