Skip to content

Commit f56bc4c

Browse files
committed
Introduced a codedisableexport app option for Collabora
1 parent b959a94 commit f56bc4c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/core/wopi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,14 @@ def checkFileInfo(fileid, acctok):
118118
# if no WebDAV URL is provided, ignore this setting
119119
pass
120120
# extensions for Collabora Online
121-
if acctok['appname'] == 'Collabora':
121+
if 'Collabora' in acctok['appname']:
122122
fmd['EnableOwnerTermination'] = True
123123
fmd['DisableExport'] = fmd['DisableCopy'] = fmd['DisablePrint'] = acctok['viewmode'] == utils.ViewMode.VIEW_ONLY
124+
if srv.config.get('apps', 'codedisableexport', fallback='False').upper() == 'TRUE':
125+
fmd['UserCanNotWriteRelative'] = fmd['DisableExport'] = True
124126

125127
res = flask.Response(json.dumps(fmd), mimetype='application/json')
128+
126129
# redact sensitive metadata for the logs
127130
if srv.config.get('general', 'loglevel') != 'Debug':
128131
fmd['HostViewUrl'] = fmd['HostEditUrl'] = fmd['DownloadUrl'] = fmd['FileUrl'] = \

src/core/wopiutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def generateAccessToken(userid, fileid, viewmode, user, folderurl, endpoint, app
229229
exptime = int(time.time()) + srv.config.getint('general', 'tokenvalidity')
230230
fname = statinfo['filepath']
231231
fext = os.path.splitext(fname)[1].lower()
232-
if appname != 'Collabora' and viewmode == ViewMode.READ_WRITE and (
232+
if 'Collabora' not in appname and viewmode == ViewMode.READ_WRITE and (
233233
fext in ('.doc', '.dot', '.xls', '.ppt', '.pps', '.csv') or
234234
fext[1:3] in ('od', 'ot') and srv.config.get('general', 'disablemswriteodf', fallback='False').upper() == 'TRUE'):
235235
# we're opening a legacy format file or an ODF (`.o[d|t]?`) and the app is not Collabora

wopiserver.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ codeofficetypes = .odt .ott .ods .ots .odp .otp .odg .otg .doc .dot .xls .xlt .x
148148
# A flag to enable early features with Microsoft Office
149149
#earlyfeatures = False
150150

151+
# A flag to disable 'Export As' in Collabora Online
152+
#codedisableexport = False
151153

152154
[security]
153155
# Location of the secret files. Requires a restart of the

0 commit comments

Comments
 (0)