Skip to content

Commit

Permalink
ServerAudit: use IsAdminUser property
Browse files Browse the repository at this point in the history
and set old is_admin inside UserExtraInfo as deprecated

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I93e6eb72a7062932e129e2f3973215cf10d83702
  • Loading branch information
eszkadev committed Jun 10, 2024
1 parent e803623 commit abd0650
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
15 changes: 11 additions & 4 deletions browser/src/control/Control.ServerAuditDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ class ServerAuditDialog {
this.errorCodes = {
is_admin: {
missing: [
_('The is_admin user property is not set'),
'SDK: userextrainfo',
'https://sdk.collaboraonline.com/docs/advanced_integration.html?highlight=userprivateinfo#userextrainfo',
_('The IsAdminUser property is not set'),
'SDK: IsAdminUser',
'https://sdk.collaboraonline.com/docs/advanced_integration.html?highlight=IsAdminUser#isadminuser',
],
ok: [_('The is_admin user property is set'), '', ''],
deprecated: [
_(
'Used deprecated id_admin field, please use IsAdminUser property instead',
),
'SDK: IsAdminUser',
'https://sdk.collaboraonline.com/docs/advanced_integration.html?highlight=IsAdminUser#isadminuser',
],
ok: [_('The IsAdminUser user property is set'), '', ''],
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,8 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
: wopiFileInfo->getWatermarkText();
const std::string templateSource = wopiFileInfo->getTemplateSource();

if (userExtraInfo.find("is_admin") == std::string::npos)
_serverAudit.set("is_admin", "missing");
if (!wopiFileInfo->getIsAdminUserError().empty())
_serverAudit.set("is_admin", wopiFileInfo->getIsAdminUserError());

_isViewFileExtension = COOLWSD::IsViewFileExtension(wopiStorage->getFileExtension());
if (!wopiFileInfo->getUserCanWrite() ||
Expand Down
10 changes: 10 additions & 0 deletions wsd/wopi/WopiStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob
JsonUtil::findJSONValue(object, "BreadcrumbDocName", _breadcrumbDocName);
JsonUtil::findJSONValue(object, "FileUrl", _fileUrl);

// check if user is admin on the integrator side
if (!JsonUtil::findJSONValue(object, "IsAdminUser", _isAdminUser))
{
_isAdminUserError = "missing";

// check deprecated is_admin inside UserExtraInfo
if (_userExtraInfo.find("is_admin") != std::string::npos)
_isAdminUserError = "deprecated";
}

// Update the scheme to https if ssl or ssl termination is on
if (_postMessageOrigin.starts_with("http://") &&
(COOLWSD::isSSLEnabled() || COOLWSD::isSSLTermination()))
Expand Down
8 changes: 8 additions & 0 deletions wsd/wopi/WopiStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class WopiStorage : public StorageBase
bool getSupportsLocks() const { return _supportsLocks; }
bool getUserCanRename() const { return _userCanRename; }

bool getIsAdminUser() const { return _isAdminUser; }
const std::string& getIsAdminUserError() const { return _isAdminUserError; }

TriState getDisableChangeTrackingShow() const { return _disableChangeTrackingShow; }
TriState getDisableChangeTrackingRecord() const { return _disableChangeTrackingRecord; }
TriState getHideChangeTrackingControls() const { return _hideChangeTrackingControls; }
Expand Down Expand Up @@ -158,6 +161,11 @@ class WopiStorage : public StorageBase
bool _supportsRename = false;
/// If user is allowed to rename the document
bool _userCanRename = false;
/// If user is considered as admin on the integrator side
bool _isAdminUser = false;

/// error code if integration does not use isAdminUser field properly
std::string _isAdminUserError = "";
};

WopiStorage(const Poco::URI& uri, const std::string& localStorePath,
Expand Down

0 comments on commit abd0650

Please sign in to comment.