Skip to content

Commit

Permalink
Bridged apps: added check to prevent misconfigurations
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Oct 5, 2022
1 parent eb22681 commit 1c4f8ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ def loadplugin(cls, appname, appurl, appinturl, apikey):
'''Load plugin for the given appname, if supported by the bridge service'''
p = appname.lower()
if p in cls.plugins:
# already initialized
# already initialized, check that the app URL matches: the current model does not support multiple app backends
if appurl != cls.plugins[p].appexturl:
cls.log.warning('msg="Attempt to use plugin with another appurl" client="%s" app="%s" appurl="%s"' %
(flask.request.remote_addr, appname, appurl))
raise KeyError(appname)
return
if not issupported(appname):
raise ValueError(appname)
Expand All @@ -91,8 +95,8 @@ def loadplugin(cls, appname, appurl, appinturl, apikey):
cls.plugins[p].init(appurl, appinturl, apikey)
cls.log.info('msg="Imported plugin for application" app="%s" plugin="%s"' % (p, cls.plugins[p]))
except Exception as e:
cls.log.info('msg="Failed to initialize plugin" app="%s" URL="%s" exception="%s"' %
(p, appinturl, e))
cls.log.warning('msg="Failed to initialize plugin" app="%s" URL="%s" exception="%s"' %
(p, appinturl, e))
cls.plugins.pop(p, None) # regardless which step failed, this will remove the failed plugin
raise ValueError(appname)

Expand Down
2 changes: 2 additions & 0 deletions src/wopiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def iopOpenInApp():
bridge.WB.loadplugin(appname, appurl, appinturl, apikey)
except ValueError:
return 'Failed to load WOPI bridge plugin for %s' % appname, http.client.INTERNAL_SERVER_ERROR
except KeyError:
return 'Bridged app %s already configured with a different appurl' % appname, http.client.NOT_IMPLEMENTED

try:
userid = storage.getuseridfromcreds(usertoken, wopiuser)
Expand Down

0 comments on commit 1c4f8ef

Please sign in to comment.