Skip to content

Commit

Permalink
[bug] Fix downloadFile for wopi; For bug https://bugzilla.onlyoffice.…
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Mar 11, 2024
1 parent 41d6ab3 commit 7326335
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions DocService/sources/canvasservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,14 @@ exports.downloadFile = function(req, res) {
isInJwtToken = true;
} else if (wopiClient.isWopiJwtToken(decoded)) {
({url, headers} = wopiClient.getWopiFileUrl(ctx, decoded.fileInfo, decoded.userAuth));
let filterStatus = yield wopiClient.checkIpFilter(ctx, url);
if (0 === filterStatus) {
//todo false? (true because it passed checkIpFilter for wopi)
//todo use directIfIn
isInJwtToken = true;
} else {
errorDescription = 'access deny';
}
} else if (!tenTokenEnableBrowser) {
//todo token required
if (decoded.url) {
Expand Down
4 changes: 3 additions & 1 deletion DocService/sources/wopiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ function checkFileInfo(ctx, wopiSrc, access_token, opt_sc) {
}
fillStandardHeaders(ctx, headers, uri, access_token);
ctx.logger.debug('wopi checkFileInfo request uri=%s headers=%j', uri, headers);
//todo false?
//todo false? (true because it passed checkIpFilter for wopi)
//todo use directIfIn
let isInJwtToken = true;
let getRes = yield utils.downloadUrlPromise(ctx, uri, tenDownloadTimeout, undefined, undefined, isInJwtToken, headers);
ctx.logger.debug(`wopi checkFileInfo headers=%j body=%s`, getRes.response.headers, getRes.body);
Expand Down Expand Up @@ -969,6 +970,7 @@ function dummyOk(req, res) {
res.sendStatus(200);
}

exports.checkIpFilter = checkIpFilter;
exports.discovery = discovery;
exports.collaboraCapabilities = collaboraCapabilities;
exports.parseWopiCallback = parseWopiCallback;
Expand Down

0 comments on commit 7326335

Please sign in to comment.