39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package apistruct
|
|
|
|
import (
|
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
|
"github.com/filecoin-project/lotus/api"
|
|
)
|
|
|
|
const (
|
|
// When changing these, update docs/API.md too
|
|
|
|
PermRead auth.Permission = "read" // default
|
|
PermWrite auth.Permission = "write"
|
|
PermSign auth.Permission = "sign" // Use wallet keys for signing
|
|
PermAdmin auth.Permission = "admin" // Manage permissions
|
|
)
|
|
|
|
var AllPermissions = []auth.Permission{PermRead, PermWrite, PermSign, PermAdmin}
|
|
var DefaultPerms = []auth.Permission{PermRead}
|
|
|
|
func PermissionedStorMinerAPI(a api.StorageMiner) api.StorageMiner {
|
|
var out StorageMinerStruct
|
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
|
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
|
|
return &out
|
|
}
|
|
|
|
func PermissionedFullAPI(a api.FullNode) api.FullNode {
|
|
var out FullNodeStruct
|
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
|
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
|
|
return &out
|
|
}
|
|
|
|
func PermissionedWorkerAPI(a api.WorkerApi) api.WorkerApi {
|
|
var out WorkerStruct
|
|
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
|
|
return &out
|
|
}
|