mirror of
https://github.com/LibreOffice/online.git
synced 2025-08-20 23:24:34 +00:00
wsd: Allow hosts to disable print, export
using these WOPI protocol extensions: DisablePrint, DisableExport, DisableCopy. All assumed to be false if not provided. Change-Id: I415597d710107f9d8cbb8757f361365cc2a88eb1
This commit is contained in:
@ -394,10 +394,35 @@ bool ClientSession::filterMessage(const std::string& message) const
|
||||
{
|
||||
bool allowed = true;
|
||||
StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
|
||||
if (isReadOnly())
|
||||
|
||||
// Set allowed flag to false depending on if particular WOPI properties are set
|
||||
if (tokens[0] == "downloadas")
|
||||
{
|
||||
std::string id;
|
||||
if (getTokenString(tokens[2], "id", id))
|
||||
{
|
||||
if (id == "print" && _wopiFileInfo && _wopiFileInfo->_disablePrint)
|
||||
{
|
||||
allowed = false;
|
||||
LOG_WRN("WOPI host has disabled print for this session");
|
||||
}
|
||||
else if (id == "export" && _wopiFileInfo && _wopiFileInfo->_disableExport)
|
||||
{
|
||||
allowed = false;
|
||||
LOG_WRN("WOPI host has disabled export for this session");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allowed = false;
|
||||
LOG_WRN("No value of id in downloadas message");
|
||||
}
|
||||
}
|
||||
else if (isReadOnly())
|
||||
{
|
||||
// By default, don't allow anything
|
||||
allowed = false;
|
||||
if (tokens[0] == "downloadas" || tokens[0] == "userinactive" || tokens[0] == "useractive")
|
||||
if (tokens[0] == "userinactive" || tokens[0] == "useractive")
|
||||
{
|
||||
allowed = true;
|
||||
}
|
||||
|
@ -390,6 +390,9 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
||||
bool hidePrintOption = false;
|
||||
bool hideSaveOption = false;
|
||||
bool hideExportOption = false;
|
||||
bool disablePrint = false;
|
||||
bool disableExport = false;
|
||||
bool disableCopy = false;
|
||||
std::string resMsg;
|
||||
Poco::StreamCopier::copyToString(rs, resMsg);
|
||||
|
||||
@ -414,6 +417,9 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
||||
getWOPIValue(object, "HideSaveOption", hideSaveOption);
|
||||
getWOPIValue(object, "HideExportOption", hideExportOption);
|
||||
getWOPIValue(object, "EnableOwnerTermination", enableOwnerTermination);
|
||||
getWOPIValue(object, "DisablePrint", disablePrint);
|
||||
getWOPIValue(object, "DisableExport", disableExport);
|
||||
getWOPIValue(object, "DisableCopy", disableCopy);
|
||||
}
|
||||
else
|
||||
Log::error("WOPI::CheckFileInfo is missing JSON payload");
|
||||
@ -424,7 +430,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po
|
||||
_fileInfo = FileInfo({filename, ownerId, Poco::Timestamp(), size});
|
||||
}
|
||||
|
||||
return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, callDuration}));
|
||||
return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, callDuration}));
|
||||
}
|
||||
|
||||
/// uri format: http://server/<...>/wopi*/files/<id>/content
|
||||
|
@ -180,6 +180,9 @@ public:
|
||||
const bool hideSaveOption,
|
||||
const bool hideExportOption,
|
||||
const bool enableOwnerTermination,
|
||||
const bool disablePrint,
|
||||
const bool disableExport,
|
||||
const bool disableCopy,
|
||||
const std::chrono::duration<double> callDuration)
|
||||
: _userid(userid),
|
||||
_username(username),
|
||||
@ -189,6 +192,9 @@ public:
|
||||
_hideSaveOption(hideSaveOption),
|
||||
_hideExportOption(hideExportOption),
|
||||
_enableOwnerTermination(enableOwnerTermination),
|
||||
_disablePrint(disablePrint),
|
||||
_disableExport(disableExport),
|
||||
_disableCopy(disableCopy),
|
||||
_callDuration(callDuration)
|
||||
{
|
||||
}
|
||||
@ -209,6 +215,12 @@ public:
|
||||
bool _hideExportOption;
|
||||
/// If WOPI host has enabled owner termination feature on
|
||||
bool _enableOwnerTermination;
|
||||
/// If WOPI host has allowed the user to print the document
|
||||
bool _disablePrint;
|
||||
/// If WOPI host has allowed the user to export the document
|
||||
bool _disableExport;
|
||||
/// If WOPI host has allowed the user to copy to/from the document
|
||||
bool _disableCopy;
|
||||
/// Time it took to call WOPI's CheckFileInfo
|
||||
std::chrono::duration<double> _callDuration;
|
||||
};
|
||||
|
Reference in New Issue
Block a user