Skip to content

Commit

Permalink
[WiP][ownCloud] Store full OCM payload (#58)
Browse files Browse the repository at this point in the history
* add: store full ocm payload [initial support for #45]

Signed-off-by: Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.io>

* add: comments

Signed-off-by: Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.io>

* modify ocm payload schema and add initial flow document

* docs: initial attempt at documenting app flow

* fix: typo in table name

* fix: syntax highlighting

* refactor: result of code review with michiel

changing controllers is still pending

* add: store ocm payload for both sending/receiving shares

* add: get server iop idp

* add: do not allow same site sm shares reach reva at all

* add: contact search json result

* add: doc comment

* fix: authenticate function to handle userid and token better

---------

Signed-off-by: Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.io>
  • Loading branch information
MahdiBaghbani authored Oct 1, 2023
1 parent 8326266 commit 0e54681
Show file tree
Hide file tree
Showing 12 changed files with 1,733 additions and 601 deletions.
191 changes: 191 additions & 0 deletions appinfo/Migrations/Version20230916.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?php
/**
* ownCloud - sciencemesh
*
* This file is licensed under the MIT License. See the LICENCE file.
* @license MIT
* @copyright Sciencemesh 2020 - 2023
*
* @author Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.ir>
*/

namespace OCA\ScienceMesh\Migrations;

use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/** Creates initial schema */
class Version20230916 implements ISchemaMigration
{
public function changeSchema(Schema $schema, array $options)
{
$prefix = $options["tablePrefix"];

// ocm_received_shares table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_shares")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_received_shares");

$table->addColumn("id", "bigint", [
"autoincrement" => true,
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("share_external_id", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("name", "string", [
"length" => 255,
"notnull" => true,
"comment" => "Original name on the remote server"
]);

$table->addColumn("share_with", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("owner", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("initiator", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("ctime", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("mtime", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("expiration", "bigint", [
"unsigned" => false,
"notnull" => false,
"default" => null,
"length" => 11,
]);

$table->addColumn("remote_share_id", "string", [
"length" => 255,
"notnull" => false,
"default" => null,
"comment" => "share ID at the remote server"
]);

$table->setPrimaryKey(["id"]);

$table->addUniqueIndex(
["share_external_id"],
"sm_ocm_rx_ex_id_idx"
);
$table->addUniqueIndex(
["share_with"],
"sm_ocm_rx_sh_w_idx"
);
}

// ocm_protocol_transfer table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_transfer")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_transfer");

$table->addColumn("ocm_received_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("source_uri", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("shared_secret", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("size", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_received_share_id"],
"sm_ocm_rx_share_id_tx_idx"
);
}

// ocm_protocol_webapp table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_webapp")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_webapp");

$table->addColumn("ocm_received_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("uri_template", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("view_mode", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_received_share_id"],
"sm_ocm_rx_share_id_app_idx"
);
}

// ocm_protocol_webdav table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_received_share_protocol_webdav")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_received_share_protocol_webdav");

$table->addColumn("ocm_received_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("uri", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("shared_secret", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("permissions", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_received_share_id"],
"sm_ocm_rx_share_id_dav_idx"
);
}
}
}
184 changes: 184 additions & 0 deletions appinfo/Migrations/Version20230917.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php
/**
* ownCloud - sciencemesh
*
* This file is licensed under the MIT License. See the LICENCE file.
* @license MIT
* @copyright Sciencemesh 2020 - 2023
*
* @author Mohammad Mahdi Baghbani Pourvahid <mahdi-baghbani@azadehafzar.ir>
*/

namespace OCA\ScienceMesh\Migrations;

use Doctrine\DBAL\Schema\Schema;
use OCP\Migration\ISchemaMigration;

/** Creates initial schema */
class Version20230917 implements ISchemaMigration
{
public function changeSchema(Schema $schema, array $options)
{
$prefix = $options["tablePrefix"];

// ocm_sent_shares table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_sent_shares")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_sent_shares");

$table->addColumn("id", "bigint", [
"autoincrement" => true,
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("share_internal_id", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("name", "string", [
"length" => 255,
"notnull" => true,
"comment" => "Original name on the sending server"
]);

$table->addColumn("share_with", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("owner", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("initiator", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("ctime", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("mtime", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("expiration", "bigint", [
"unsigned" => false,
"notnull" => false,
"default" => null,
"length" => 11,
]);

$table->setPrimaryKey(["id"]);

$table->addUniqueIndex(
["share_internal_id"],
"sm_ocm_tx_in_id_idx"
);
$table->addUniqueIndex(
["share_with"],
"sm_ocm_rx_sh_w_idx"
);
}

// ocm_protocol_transfer table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_sent_share_protocol_transfer")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_sent_share_protocol_transfer");

$table->addColumn("ocm_sent_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("source_uri", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("shared_secret", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("size", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_sent_share_id"],
"sm_ocm_tx_share_id_tx_idx"
);
}

// ocm_protocol_webapp table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_sent_share_protocol_webapp")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_sent_share_protocol_webapp");

$table->addColumn("ocm_sent_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("uri_template", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("view_mode", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_sent_share_id"],
"sm_ocm_tx_share_id_app_idx"
);
}

// ocm_protocol_webdav table.
if (!$schema->hasTable("{$prefix}sciencemesh_ocm_sent_share_protocol_webdav")) {
$table = $schema->createTable("{$prefix}sciencemesh_ocm_sent_share_protocol_webdav");

$table->addColumn("ocm_sent_share_id", "bigint", [
"unsigned" => true,
"notnull" => true,
"length" => 11,
]);

$table->addColumn("uri", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("shared_secret", "string", [
"length" => 255,
"notnull" => true,
]);

$table->addColumn("permissions", "bigint", [
"unsigned" => false,
"notnull" => true,
"length" => 11,
]);

$table->addUniqueIndex(
["ocm_sent_share_id"],
"sm_ocm_tx_share_id_dav_idx"
);
}
}
}
2 changes: 2 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<admin>OCA\ScienceMesh\Sections\SciencemeshSettingsAdmin</admin>
</settings-sections>

<use-migrations>true</use-migrations>

<navigations>
<navigation>
<name>ScienceMesh</name>
Expand Down
Loading

0 comments on commit 0e54681

Please sign in to comment.