Skip to content

Commit 3f73460

Browse files
committed
(optional) multi: add public price oracle flag
1 parent bee379f commit 3f73460

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type RPCConfig struct {
5353

5454
AllowPublicStats bool
5555

56+
AllowPublicPriceOracle bool
57+
5658
LetsEncryptDir string
5759

5860
LetsEncryptListen string

perms/perms.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ var (
336336
// macaroon authentication.
337337
func MacaroonWhitelist(allowUniPublicAccessRead bool,
338338
allowUniPublicAccessWrite bool, allowPublicUniProofCourier bool,
339-
allowPublicStats bool) map[string]struct{} {
339+
allowPublicStats bool, allowPublicPriceOracle bool,
340+
) map[string]struct{} {
340341

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

365+
// Conditionally add public price oracle RPC endpoints to the whitelist.
366+
if allowPublicPriceOracle {
367+
whitelist["/priceoraclerpc.PriceOracle/QueryAssetRates"] = struct{}{} // nolint: lll
368+
}
369+
364370
return whitelist
365371
}

sample-tapd.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
; Disable macaroon authentication for stats RPC endpoints
129129
; allow-public-stats=false
130130

131+
; Disble macaroon authentication for price oracle proxy RPC endpoints
132+
; allow-public-price-oracle=false
133+
131134
; Add an ip:port/hostname to allow cross origin access from
132135
; To allow all origins, set as "*"
133136
; restcors=

server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ func (s *Server) RunUntilShutdown(mainErrChan <-chan error) error {
315315
s.cfg.UniversePublicAccess.IsWriteAccessGranted(),
316316
s.cfg.RPCConfig.AllowPublicUniProofCourier,
317317
s.cfg.RPCConfig.AllowPublicStats,
318+
s.cfg.RPCConfig.AllowPublicPriceOracle,
318319
)
319320

320321
// Create a new RPC interceptor that we'll add to the GRPC server. This

tapcfg/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ type RpcConfig struct {
238238

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

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

0 commit comments

Comments
 (0)