From ac1146a3a0202828e6d740860d30df4e83e15790 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Fri, 3 Sep 2021 10:26:30 +0200 Subject: [PATCH 1/2] Fail initialization if app is unsupported --- changelog/unreleased/appprovider-unsupported.md | 5 +++++ pkg/app/provider/wopi/wopi.go | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog/unreleased/appprovider-unsupported.md diff --git a/changelog/unreleased/appprovider-unsupported.md b/changelog/unreleased/appprovider-unsupported.md new file mode 100644 index 0000000000..271ccb4fa9 --- /dev/null +++ b/changelog/unreleased/appprovider-unsupported.md @@ -0,0 +1,5 @@ +Enhancement: fail initialization of a WOPI AppProvider if +the underlying app is not WOPI-compliant nor it is supported +by the WOPI bridge extensions + +https://github.com/cs3org/reva/pull/2034 diff --git a/pkg/app/provider/wopi/wopi.go b/pkg/app/provider/wopi/wopi.go index 0f731d76af..7556a91070 100644 --- a/pkg/app/provider/wopi/wopi.go +++ b/pkg/app/provider/wopi/wopi.go @@ -287,17 +287,18 @@ func getAppURLs(c *config) (map[string]map[string]string, error) { // scrape app's home page to find the appname if !strings.Contains(buf.String(), c.AppName) { - // || (c.AppName != "CodiMD" && c.AppName != "Etherpad") { return nil, errors.New("Application server at " + c.AppURL + " does not match this AppProvider for " + c.AppName) } // register the supported mimetypes in the AppRegistry: this is hardcoded for the time being - if c.AppName == "CodiMD" { + switch c.AppName { + case "CodiMD": appURLs = getCodimdExtensions(c.AppURL) - } else if c.AppName == "Etherpad" { + case "Etherpad": appURLs = getEtherpadExtensions(c.AppURL) + default: + return nil, errors.New("Application server " + c.AppName + " running at " + c.AppURL + " is unsupported") } - } return appURLs, nil } @@ -370,7 +371,7 @@ func getCodimdExtensions(appURL string) map[string]map[string]string { func getEtherpadExtensions(appURL string) map[string]map[string]string { appURLs := make(map[string]map[string]string) appURLs["edit"] = map[string]string{ - ".etherpad": appURL, + ".epd": appURL, } return appURLs } From d35480a7d4e1f985f3ea93e0115e36b9bd5b6e03 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Fri, 3 Sep 2021 15:19:05 +0200 Subject: [PATCH 2/2] Also removed obsoleted comment As the frontend uses a separate tab, the folderurl argument becomes less relevant and WOPI will hide its breadcrumb when missing --- pkg/app/provider/wopi/wopi.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/app/provider/wopi/wopi.go b/pkg/app/provider/wopi/wopi.go index 7556a91070..1c7600c940 100644 --- a/pkg/app/provider/wopi/wopi.go +++ b/pkg/app/provider/wopi/wopi.go @@ -136,9 +136,6 @@ func (p *wopiProvider) GetAppURL(ctx context.Context, resource *provider.Resourc q.Add("fileid", resource.GetId().OpaqueId) q.Add("endpoint", resource.GetId().StorageId) q.Add("viewmode", viewMode.String()) - // TODO the folder URL should be resolved as e.g. `'https://cernbox.cern.ch/index.php/apps/files/?dir=' + filepath.Dir(req.Ref.GetPath())` - // or should be deprecated/removed altogether, needs discussion and decision. - // q.Add("folderurl", "...") u, ok := ctxpkg.ContextGetUser(ctx) if ok { // else defaults to "Anonymous Guest" q.Add("username", u.Username)