lotus/api/apistruct/permissioned.go

39 lines
1.2 KiB
Go
Raw Normal View History

2019-12-09 17:08:32 +00:00
package apistruct
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-12-09 17:08:32 +00:00
"github.com/filecoin-project/lotus/api"
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
2019-12-09 17:08:32 +00:00
func PermissionedStorMinerAPI(a api.StorageMiner) api.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
}
2019-12-09 17:08:32 +00:00
func PermissionedFullAPI(a api.FullNode) api.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
2020-03-13 01:37:38 +00:00
func PermissionedWorkerAPI(a api.WorkerApi) api.WorkerApi {
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
}