Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward OpenFileInAppProvider calls for OCM shares to remote reva #1140

Merged
merged 10 commits into from
Sep 18, 2020
7 changes: 7 additions & 0 deletions changelog/unreleased/appprovider-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Call the gateway stat method from appprovider

The appprovider service used to directly pass the stat request to the storage
provider bypassing the gateway, which resulted in errors while handling share
children as they are resolved in the gateway path.

https://github.com/cs3org/reva/pull/1140
4 changes: 2 additions & 2 deletions cmd/reva/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var configureCommand = func() *command {
return err
}

c := &config{Host: text}
if err := writeConfig(c); err != nil {
conf = &config{Host: text}
if err := writeConfig(conf); err != nil {
return err
}
fmt.Println("config saved at ", getConfigFile())
Expand Down
4 changes: 2 additions & 2 deletions cmd/reva/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ var (
func init() {
flag.StringVar(&host, "host", "", "address of the GRPC gateway host")
flag.BoolVar(&insecure, "insecure", false, "disables grpc transport security")
flag.BoolVar(&skipverify, "skip-verify", false, "whether a client verifies the server's certificate chain and host name.")
flag.BoolVar(&disableargprompt, "disable-arg-prompt", false, "whether to disable prompts for command arguments.")
flag.BoolVar(&skipverify, "skip-verify", false, "whether to skip verifying the server's certificate chain and host name")
flag.BoolVar(&disableargprompt, "disable-arg-prompt", false, "whether to disable prompts for command arguments")
flag.IntVar(&timeout, "timout", -1, "the timeout in seconds for executing the commands, -1 means no timeout")
flag.Parse()
}
Expand Down
17 changes: 16 additions & 1 deletion cmd/reva/open-file-in-app-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/pkg/errors"
)

Expand All @@ -35,9 +36,13 @@ func openFileInAppProviderCommand() *command {
return "Usage: open-file-in-app-provider [-flags] [-viewmode view|read|write] <path>"
}
viewMode := cmd.String("viewmode", "view", "the view permissions, defaults to view")
insecureFlag := cmd.Bool("insecure", false, "disables grpc transport security")
skipVerifyFlag := cmd.Bool("skip-verify", false, "whether to skip verifying remote reva's certificate chain and host name")

cmd.ResetFlags = func() {
*viewMode = "view"
*insecureFlag = false
*skipVerifyFlag = false
}

cmd.Action = func(w ...io.Writer) error {
Expand All @@ -58,7 +63,17 @@ func openFileInAppProviderCommand() *command {
Spec: &provider.Reference_Path{Path: path},
}

openRequest := &gateway.OpenFileInAppProviderRequest{Ref: ref, ViewMode: vm}
opaqueObj := &typespb.Opaque{
Map: map[string]*typespb.OpaqueEntry{},
}
if *insecureFlag {
opaqueObj.Map["insecure"] = &typespb.OpaqueEntry{}
}
if *skipVerifyFlag {
opaqueObj.Map["skip-verify"] = &typespb.OpaqueEntry{}
}

openRequest := &gateway.OpenFileInAppProviderRequest{Ref: ref, ViewMode: vm, Opaque: opaqueObj}

openRes, err := client.OpenFileInAppProvider(ctx, openRequest)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ description: >
# _struct: config_

{{% dir name="iopsecret" type="string" default="" %}}
The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L60)
The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L58)
{{< highlight toml >}}
[grpc.services.appprovider]
iopsecret = ""
{{< /highlight >}}
{{% /dir %}}

{{% dir name="wopiurl" type="string" default="" %}}
The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L61)
The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L59)
{{< highlight toml >}}
[grpc.services.appprovider]
wopiurl = ""
Expand Down
52 changes: 52 additions & 0 deletions examples/ocmd/providers.demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
},
"api_version": "0.0.1",
"host": "http://127.0.0.1:19001/"
},
{
"endpoint": {
"type": {
"name": "Gateway",
"description": "CERNBox GRPC Gateway"
},
"name": "CERNBox - GRPC Gateway",
"path": "127.0.0.1:19000",
"is_monitored": true
},
"api_version": "0.0.1",
"host": "127.0.0.1:19000"
}
]
},
Expand Down Expand Up @@ -68,6 +81,19 @@
},
"api_version": "0.0.1",
"host": "http://127.0.0.1:17001/"
},
{
"endpoint": {
"type": {
"name": "Gateway",
"description": "CESNET GRPC Gateway"
},
"name": "CESNET - GRPC Gateway",
"path": "127.0.0.1:17000",
"is_monitored": true
},
"api_version": "0.0.1",
"host": "127.0.0.1:17000"
}
]
},
Expand Down Expand Up @@ -104,6 +130,19 @@
},
"api_version": "0.0.1",
"host": "http://127.0.0.1:19001/"
},
{
"endpoint": {
"type": {
"name": "Gateway",
"description": "Example GRPC Gateway"
},
"name": "Example - GRPC Gateway",
"path": "127.0.0.1:19000",
"is_monitored": true
},
"api_version": "0.0.1",
"host": "127.0.0.1:19000"
}
]
},
Expand Down Expand Up @@ -140,6 +179,19 @@
},
"api_version": "0.0.1",
"host": "http://127.0.0.1:19001/"
},
{
"endpoint": {
"type": {
"name": "Gateway",
"description": "Test GRPC Gateway"
},
"name": "Test - GRPC Gateway",
"path": "127.0.0.1:19000",
"is_monitored": true
},
"api_version": "0.0.1",
"host": "127.0.0.1:19000"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3XzgoqakqQEsnZf9LdXdi2nkI=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down
6 changes: 2 additions & 4 deletions internal/grpc/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"path"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -135,7 +133,7 @@ func (s *service) getWopiAppEndpoints(ctx context.Context) (map[string]interface
}
defer appsRes.Body.Close()
if appsRes.StatusCode != http.StatusOK {
return nil, errors.New("Request to WOPI server returned " + string(appsRes.StatusCode))
return nil, fmt.Errorf("Request to WOPI server returned %d", appsRes.StatusCode)
}
appsBody, err := ioutil.ReadAll(appsRes.Body)
if err != nil {
Expand Down Expand Up @@ -207,7 +205,7 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope

if openRes.StatusCode != http.StatusOK {
res := &providerpb.OpenFileInAppProviderResponse{
Status: status.NewInvalid(ctx, "appprovider: error performing open request to WOPI, status code: "+strconv.Itoa(openRes.StatusCode)),
Status: status.NewInvalid(ctx, fmt.Sprintf("appprovider: error performing open request to WOPI, status code: %d", openRes.StatusCode)),
}
return res, nil
}
Expand Down
Loading