From 1d2fbb3710d54aea7ce6e05081f40e31dd6a5cdf Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Tue, 5 Mar 2024 02:00:06 +0300 Subject: [PATCH] [wopi] Fix wopi url for pdf checker without jwt token; For bug 62643 --- apps/api/wopi/editor-wopi.ejs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/api/wopi/editor-wopi.ejs b/apps/api/wopi/editor-wopi.ejs index fc342779bf..82e45d1610 100644 --- a/apps/api/wopi/editor-wopi.ejs +++ b/apps/api/wopi/editor-wopi.ejs @@ -247,6 +247,19 @@ div { innerAlert(event.data); }; + var getWopiFileUrl = function(fileInfo, userAuth) { + let url; + if (fileInfo.FileUrl) { + //Requests to the FileUrl can not be signed using proof keys. The FileUrl is used exactly as provided by the host, so it does not necessarily include the access token, which is required to construct the expected proof. + url = fileInfo.FileUrl; + } else if (fileInfo.TemplateSource) { + url = fileInfo.TemplateSource; + } else if (userAuth) { + url = userAuth.wopiSrc + "/contents?access_token=" + userAuth.access_token; + } + return url; + } + var connectEditor = function () { fileInfo = <%- JSON.stringify(fileInfo) %>; @@ -280,7 +293,7 @@ div { "token": token, "document": { "title": fileInfo.BreadcrumbDocName || fileInfo.BaseFileName, - "url": userAuth.wopiSrc, + "url": getWopiFileUrl(fileInfo, userAuth), "fileType": fileType, "key": key, "info": {