backend infrastructure for 'channel protection password'; which will be used to optionally encrypt export files and resolve channel/identity ownership/hijacking disputes

This commit is contained in:
zotlabs 2017-04-12 17:32:28 -07:00
parent 63dd6ad01a
commit 1c32564536
6 changed files with 25 additions and 5 deletions

View File

@ -53,7 +53,7 @@ define ( 'STD_VERSION', '5.3' );
define ( 'ZOT_REVISION', '1.2' ); define ( 'ZOT_REVISION', '1.2' );
define ( 'DB_UPDATE_VERSION', 1188 ); define ( 'DB_UPDATE_VERSION', 1189 );
define ( 'PROJECT_BASE', __DIR__ ); define ( 'PROJECT_BASE', __DIR__ );

View File

@ -538,6 +538,8 @@ function identity_basic_export($channel_id, $sections = null) {
$ret['relocate'] = [ 'channel_address' => $r[0]['channel_address'], 'url' => z_root()]; $ret['relocate'] = [ 'channel_address' => $r[0]['channel_address'], 'url' => z_root()];
if(in_array('channel',$sections)) { if(in_array('channel',$sections)) {
$ret['channel'] = $r[0]; $ret['channel'] = $r[0];
unset($ret['channel']['channel_password']);
unset($ret['channel']['channel_salt']);
} }
} }
@ -1999,7 +2001,10 @@ function channel_store_lowlevel($arr) {
'channel_deny_gid' => ((array_key_exists('channel_deny_gid',$arr)) ? $arr['channel_deny_gid'] : ''), 'channel_deny_gid' => ((array_key_exists('channel_deny_gid',$arr)) ? $arr['channel_deny_gid'] : ''),
'channel_removed' => ((array_key_exists('channel_removed',$arr)) ? $arr['channel_removed'] : '0'), 'channel_removed' => ((array_key_exists('channel_removed',$arr)) ? $arr['channel_removed'] : '0'),
'channel_system' => ((array_key_exists('channel_system',$arr)) ? $arr['channel_system'] : '0'), 'channel_system' => ((array_key_exists('channel_system',$arr)) ? $arr['channel_system'] : '0'),
'channel_moved' => ((array_key_exists('channel_moved',$arr)) ? $arr['channel_moved'] : '')
'channel_moved' => ((array_key_exists('channel_moved',$arr)) ? $arr['channel_moved'] : ''),
'channel_password' => ((array_key_exists('channel_password',$arr)) ? $arr['channel_password'] : ''),
'channel_salt' => ((array_key_exists('channel_salt',$arr)) ? $arr['channel_salt'] : '')
]; ];

View File

@ -82,7 +82,7 @@ function import_channel($channel, $account_id, $seize) {
'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall', 'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall',
'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall', 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish', 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
'channel_a_delegate', 'perm_limits' 'channel_a_delegate', 'perm_limits', 'channel_password', 'channel_salt'
]; ];
$clean = array(); $clean = array();

View File

@ -265,6 +265,8 @@ CREATE TABLE IF NOT EXISTS `channel` (
`channel_removed` tinyint(1) NOT NULL DEFAULT '0', `channel_removed` tinyint(1) NOT NULL DEFAULT '0',
`channel_system` tinyint(1) NOT NULL DEFAULT '0', `channel_system` tinyint(1) NOT NULL DEFAULT '0',
`channel_moved` char(255) NOT NULL DEFAULT '', `channel_moved` char(255) NOT NULL DEFAULT '',
`channel_password` varchar(255) NOT NULL,
`channel_salt` varchar(255) NOT NULL,
PRIMARY KEY (`channel_id`), PRIMARY KEY (`channel_id`),
UNIQUE KEY `channel_address_unique` (`channel_address`), UNIQUE KEY `channel_address_unique` (`channel_address`),
KEY `channel_account_id` (`channel_account_id`), KEY `channel_account_id` (`channel_account_id`),

View File

@ -166,7 +166,7 @@ CREATE TABLE "attach" (
"is_photo" smallint NOT NULL DEFAULT '0', "is_photo" smallint NOT NULL DEFAULT '0',
"os_storage" smallint NOT NULL DEFAULT '0', "os_storage" smallint NOT NULL DEFAULT '0',
"os_path" text NOT NULL, "os_path" text NOT NULL,
"display_path" text NOT NULL, 4 "display_path" text NOT NULL,
"content" bytea NOT NULL, "content" bytea NOT NULL,
"created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
"edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00',
@ -258,6 +258,8 @@ CREATE TABLE "channel" (
"channel_removed" smallint NOT NULL DEFAULT '0', "channel_removed" smallint NOT NULL DEFAULT '0',
"channel_system" smallint NOT NULL DEFAULT '0', "channel_system" smallint NOT NULL DEFAULT '0',
"channel_moved" text NOT NULL DEFAULT '', "channel_moved" text NOT NULL DEFAULT '',
"channel_password" varchar(255) NOT NULL,
"channel_salt" varchar(255) NOT NULL,
PRIMARY KEY ("channel_id"), PRIMARY KEY ("channel_id"),
UNIQUE ("channel_address") UNIQUE ("channel_address")
); );

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1188 ); define( 'UPDATE_VERSION' , 1189 );
/** /**
* *
@ -2510,3 +2510,14 @@ function update_r1187() {
} }
function update_r1188() {
$r1 = q("alter table channel add channel_password varchar(255) not null ");
$r2 = q("alter table channel add channel_salt varchar(255) not null ");
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}