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

Fail initialization if app is unsupported #2034

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/appprovider-unsupported.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 6 additions & 8 deletions pkg/app/provider/wopi/wopi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -287,17 +284,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
}
Expand Down Expand Up @@ -370,7 +368,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
}