Skip to content

Commit

Permalink
(optional) multi: add public price oracle flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sputn1ck committed Feb 18, 2025
1 parent ee43143 commit 1ecfdf1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type RPCConfig struct {

AllowPublicStats bool

AllowPublicPriceOracle bool

LetsEncryptDir string

LetsEncryptListen string
Expand Down
8 changes: 7 additions & 1 deletion perms/perms.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ var (
// macaroon authentication.
func MacaroonWhitelist(allowUniPublicAccessRead bool,
allowUniPublicAccessWrite bool, allowPublicUniProofCourier bool,
allowPublicStats bool) map[string]struct{} {
allowPublicStats bool, allowPublicPriceOracle bool,
) map[string]struct{} {

// Make a copy of the default whitelist.
whitelist := make(map[string]struct{})
Expand All @@ -361,5 +362,10 @@ func MacaroonWhitelist(allowUniPublicAccessRead bool,
whitelist["/universerpc.Universe/QueryEvents"] = struct{}{}
}

// Conditionally add public price oracle RPC endpoints to the whitelist.
if allowPublicPriceOracle {
whitelist["/priceoraclerpc.PriceOracle/QueryAssetRates"] = struct{}{} // nolint: lll
}

return whitelist
}
3 changes: 3 additions & 0 deletions sample-tapd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
; Disable macaroon authentication for stats RPC endpoints
; allow-public-stats=false

; Disble macaroon authentication for price oracle proxy RPC endpoints
; allow-public-price-oracle=false

; Add an ip:port/hostname to allow cross origin access from
; To allow all origins, set as "*"
; restcors=
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func (s *Server) RunUntilShutdown(mainErrChan <-chan error) error {
s.cfg.UniversePublicAccess.IsWriteAccessGranted(),
s.cfg.RPCConfig.AllowPublicUniProofCourier,
s.cfg.RPCConfig.AllowPublicStats,
s.cfg.RPCConfig.AllowPublicPriceOracle,
)

// Create a new RPC interceptor that we'll add to the GRPC server. This
Expand Down
1 change: 1 addition & 0 deletions tapcfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ type RpcConfig struct {

AllowPublicUniProofCourier bool `long:"allow-public-uni-proof-courier" description:"Disable macaroon authentication for universe proof courier RPC endpoints."`
AllowPublicStats bool `long:"allow-public-stats" description:"Disable macaroon authentication for stats RPC endpoints."`
AllowPublicPriceOracle bool `long:"allow-public-price-oracle" description:"Disable macaroon authentication for price oracle RPC endpoints."`

RestCORS []string `long:"restcors" description:"Add an ip:port/hostname to allow cross origin access from. To allow all origins, set as \"*\"."`

Expand Down

0 comments on commit 1ecfdf1

Please sign in to comment.