Skip to content

Commit

Permalink
fix(grpc): add basic check for grpc configuration to check basic auth (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja7ad authored Aug 4, 2024
1 parent 22a62ae commit 36bfcce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
12 changes: 12 additions & 0 deletions www/grpc/config.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand All @@ -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
}

0 comments on commit 36bfcce

Please sign in to comment.