diff --git a/api/permissioned.go b/api/permissioned.go deleted file mode 100644 index 37ebc62..0000000 --- a/api/permissioned.go +++ /dev/null @@ -1,24 +0,0 @@ -package api - -import ( - "github.com/filecoin-project/go-jsonrpc/auth" -) - -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 PermissionedMinerAPI(a MinerAPI) MinerAPI { - var out MinerAPIStruct - auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal) - auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal) - return &out -} diff --git a/cmd/run.go b/cmd/run.go index 07aa5c3..34346f4 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/venus/venus-shared/api/chain" + "github.com/filecoin-project/venus/venus-shared/api/permission" "github.com/gorilla/mux" "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" @@ -204,7 +205,13 @@ var runCmd = &cli.Command{ }, } -func serveRPC(minerAPI lapi.MinerAPI, stop node.StopFunc, addr multiaddr.Multiaddr, shutdownChan chan struct{}, maxRequestSize int64, localJwtClient, remoteJwtAuthClient jwtclient.IJwtAuthClient) error { +func serveRPC(minerAPI lapi.MinerAPI, + stop node.StopFunc, + addr multiaddr.Multiaddr, + shutdownChan chan struct{}, + maxRequestSize int64, + localJwtClient, remoteJwtAuthClient jwtclient.IJwtAuthClient, +) error { lst, err := manet.Listen(addr) if err != nil { return fmt.Errorf("could not listen: %w", err) @@ -215,8 +222,11 @@ func serveRPC(minerAPI lapi.MinerAPI, stop node.StopFunc, addr multiaddr.Multiad serverOptions = append(serverOptions, jsonrpc.WithMaxRequestSize(maxRequestSize)) } + minerAPIStruct := &lapi.MinerAPIStruct{} + permission.PermissionProxy(minerAPI, minerAPIStruct) + rpcServer := jsonrpc.NewServer(serverOptions...) - rpcServer.Register("Filecoin", lapi.PermissionedMinerAPI(minerAPI)) + rpcServer.Register("Filecoin", minerAPIStruct) mux := mux.NewRouter() mux.Handle("/rpc/v0", jwtclient.NewAuthMux(localJwtClient, remoteJwtAuthClient, rpcServer)) diff --git a/go.mod b/go.mod index db39441..3f90840 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,8 @@ require ( github.com/filecoin-project/go-state-types v0.11.1 github.com/filecoin-project/specs-actors/v2 v2.3.6 github.com/filecoin-project/specs-actors/v7 v7.0.1 - github.com/filecoin-project/venus v1.11.0 - github.com/filecoin-project/venus-auth v1.11.0 + github.com/filecoin-project/venus v1.11.2-0.20230511060025-c6ed196f613c + github.com/filecoin-project/venus-auth v1.11.1-0.20230511013901-7829b3effbcd github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 diff --git a/go.sum b/go.sum index b7ac623..4a72fa5 100644 --- a/go.sum +++ b/go.sum @@ -410,11 +410,11 @@ github.com/filecoin-project/specs-storage v0.2.2/go.mod h1:6cc/lncmAxMUocPi0z1EP github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI= github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E= github.com/filecoin-project/venus v1.2.4/go.mod h1:hJULXHGAnWuq5S5KRtPkwbT8DqgM9II7NwyNU7t59D0= -github.com/filecoin-project/venus v1.11.0 h1:cH7ydd+O2dw7zg8tKfeiuwVd5SokZ8TBu+WoBU60pAA= -github.com/filecoin-project/venus v1.11.0/go.mod h1:H8A3djsrHKRWuKnJI/8Y6xZRudbV9V2x5NIP8/PVPfQ= +github.com/filecoin-project/venus v1.11.2-0.20230511060025-c6ed196f613c h1:f8ZwGwjnGTa4mlH8x7yqKTdw+AIcHMUd6hO2AtwRokQ= +github.com/filecoin-project/venus v1.11.2-0.20230511060025-c6ed196f613c/go.mod h1:DA73O3dB54B9dxxxQncq0ZGy5f+zwY+hRMgnaiHdhrk= github.com/filecoin-project/venus-auth v1.3.2/go.mod h1:m5Jog2GYxztwP7w3m/iJdv/V1/bTcAVU9rm/CbhxRQU= -github.com/filecoin-project/venus-auth v1.11.0 h1:9PBswWxc113vqaHABMcRyMm+1BtlJCwOFTPQJg/OVtQ= -github.com/filecoin-project/venus-auth v1.11.0/go.mod h1:aBfIfNxQkdcY8Rk5wrQn9qRtJpH4RTDdc10Ac+ferzs= +github.com/filecoin-project/venus-auth v1.11.1-0.20230511013901-7829b3effbcd h1:l02UJuEbSUIBi3NC/+17K2gBbAzsUNQg42rNCXskOBc= +github.com/filecoin-project/venus-auth v1.11.1-0.20230511013901-7829b3effbcd/go.mod h1:PoTmfEn5lljjAQThBzX0+friJYGgi7Z3VLLujkOkCT4= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=