lotus/api/permissioned.go

44 lines
1.3 KiB
Go
Raw Permalink Normal View History

2021-03-25 14:09:50 +00:00
package api
2019-07-18 16:51:21 +00:00
import (
2020-05-20 18:23:51 +00:00
"github.com/filecoin-project/go-jsonrpc/auth"
2019-07-18 16:51:21 +00:00
)
const (
2019-07-23 20:15:29 +00:00
// When changing these, update docs/API.md too
2020-05-20 18:23:51 +00:00
PermRead auth.Permission = "read" // default
PermWrite auth.Permission = "write"
PermSign auth.Permission = "sign" // Use wallet keys for signing
PermAdmin auth.Permission = "admin" // Manage permissions
2019-07-18 16:51:21 +00:00
)
2020-05-20 18:23:51 +00:00
var AllPermissions = []auth.Permission{PermRead, PermWrite, PermSign, PermAdmin}
var DefaultPerms = []auth.Permission{PermRead}
2019-07-18 16:51:21 +00:00
2021-03-25 14:09:50 +00:00
func PermissionedStorMinerAPI(a StorageMiner) StorageMiner {
2019-07-24 01:10:26 +00:00
var out StorageMinerStruct
2020-05-20 18:23:51 +00:00
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
2019-07-24 01:10:26 +00:00
return &out
}
2021-03-25 14:09:50 +00:00
func PermissionedFullAPI(a FullNode) FullNode {
2019-07-24 00:09:34 +00:00
var out FullNodeStruct
2020-05-20 18:23:51 +00:00
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
2019-07-24 01:10:26 +00:00
return &out
}
2019-07-18 16:51:21 +00:00
2021-03-25 14:09:50 +00:00
func PermissionedWorkerAPI(a Worker) Worker {
2020-03-13 01:37:38 +00:00
var out WorkerStruct
2020-05-20 18:23:51 +00:00
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
2020-03-13 01:37:38 +00:00
return &out
}
2020-09-05 19:36:32 +00:00
2021-03-25 14:09:50 +00:00
func PermissionedWalletAPI(a Wallet) Wallet {
2020-09-05 19:36:32 +00:00
var out WalletStruct
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
return &out
}