Add option to allow unrestricted API access
Kristoffer Ström committed
May 10, 2015 at 22:25 UTC
30f674af0e635637fa938c6fabeba047c84b9338
1 file changed
+6
cmd/ipfs/daemon.go
+6
@@ -28,6 +28,7 @@ const (
28
writableKwd = "writable"
29
ipfsMountKwd = "mount-ipfs"
30
ipnsMountKwd = "mount-ipns"
31
+ unrestrictedApiAccess = "unrestricted-api"
32
// apiAddrKwd = "address-api"
33
// swarmAddrKwd = "address-swarm"
34
)
@@ -71,6 +72,7 @@ the port as you would other services or database (firewall, authenticated proxy,
72
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
73
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount)"),
74
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount)"),
75
+ cmds.BoolOption(unrestrictedApiAccess, "Allow API access to unlisted hashes"),
76
77
// TODO: add way to override addresses. tricky part: updating the config if also --init.
78
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
@@ -281,6 +283,10 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
283
Writable: true,
284
BlockList: &corehttp.BlockList{
285
Decider: func(s string) bool {
286
+ unrestricted, _, _ := req.Option(unrestrictedApiAccess).Bool()
287
+ if unrestricted {
288
+ return true
289
+ }
290
// for now, only allow paths in the WebUI path
291
for _, webuipath := range corehttp.WebUIPaths {
292
if strings.HasPrefix(s, webuipath) {