-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put infrastructure in place to restrict access to a OO document serve…
…r to some projects All what is needed in the backend side is in place to make possible to restrict a OO document server to some specific projects. No changes are made yet in the web UI so there is no user facing changes yet. To test you can set explicitly the column `is_project_restricted` in the table `plugin_onlyoffice_document_server` to true and add some restrictions in the table `plugin_onlyoffice_document_server_project_restriction`. Part of story #29981: restrict an OnlyOffice server to some projects only Change-Id: Id62c7ae7e4f86c4391b1e1fc385b345226d9dcea
- Loading branch information
Showing
23 changed files
with
317 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugins/onlyoffice/db/mysql/2022/202212201015_create_server_project_restriction_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Enalean, 2022-Present. All Rights Reserved. | ||
* | ||
* This file is a part of Tuleap. | ||
* | ||
* Tuleap is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Tuleap is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace,Squiz.Classes.ValidClassName.NotCamelCaps | ||
final class b202212201015_create_server_project_restriction_table extends \Tuleap\ForgeUpgrade\Bucket | ||
{ | ||
public function description(): string | ||
{ | ||
return 'Create table plugin_onlyoffice_document_server_project_restriction'; | ||
} | ||
|
||
public function up(): void | ||
{ | ||
$this->api->createTable( | ||
'plugin_onlyoffice_document_server_project_restriction', | ||
'CREATE TABLE plugin_onlyoffice_document_server_project_restriction( | ||
project_id INT(11) NOT NULL, | ||
server_id INT(11) NOT NULL, | ||
PRIMARY KEY (project_id, server_id), | ||
UNIQUE idx_project_id(project_id) | ||
) ENGINE=InnoDB;' | ||
); | ||
if ($this->api->columnNameExists('plugin_onlyoffice_document_server', 'is_project_restricted')) { | ||
return; | ||
} | ||
|
||
$this->api->dbh->exec('ALTER TABLE plugin_onlyoffice_document_server ADD COLUMN is_project_restricted BOOLEAN NOT NULL DEFAULT FALSE'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
plugins/onlyoffice/include/DocumentServer/DocumentServerProjectRestrictionDAO.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright (c) Enalean, 2022 - Present. All Rights Reserved. | ||
* | ||
* This file is a part of Tuleap. | ||
* | ||
* Tuleap is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Tuleap is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tuleap\OnlyOffice\DocumentServer; | ||
|
||
use Tuleap\DB\DataAccessObject; | ||
|
||
class DocumentServerProjectRestrictionDAO extends DataAccessObject | ||
{ | ||
public function removeProjectFromRestriction(\Project $project): void | ||
{ | ||
$this->getDB()->delete('plugin_onlyoffice_document_server_project_restriction', ['project_id' => $project->getID()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.