Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Account #2472

Merged
merged 41 commits into from
May 17, 2018
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3689cda
web: add php pages for support of right to erasure
Apr 10, 2018
27b1274
web: add feature flag to only show delete account if
Apr 16, 2018
5ed98ba
web: Implement remove_account_request page
Apr 17, 2018
2e857de
Merge branch 'master' into knr_right_to_erase
Apr 17, 2018
3cac897
web: Implement delete_account_request_action.php (verify password,
Apr 17, 2018
a726238
web: complete UI for delete account
Apr 18, 2018
00440ad
web: refactor delete account pages to reduce duplicate code
Apr 18, 2018
059d4e0
Merge branch 'knr_token2' into knr_right_to_erase
Apr 18, 2018
501c9a5
web: At request of David, consolidate form and action pages into a
Apr 18, 2018
0485c36
Merge branch 'master' into knr_right_to_erase
Apr 30, 2018
da81c49
web: Update calls to get and validate tokens to match changed code
Apr 30, 2018
65c7cfd
web: add switch to choose which type of account delete should be
Apr 30, 2018
fb85bd3
Merge branch 'master' into knr_right_to_erase
Apr 30, 2018
2e360d6
web: integrate changes from PR 2445 into new delete account/right to be
Apr 30, 2018
fd06682
web: add table definitions for user_deleted and host_deleted
Apr 30, 2018
d67a8c4
web: add <enable_delete_account>0</enable_delete_account> to default
May 1, 2018
e821de2
web: add logic to insert into user_deleted and host_deleted when
May 1, 2018
4002f6d
web: add logic to insert into user_deleted and host_deleted when account
May 2, 2018
b7bb437
web: change primary key for user_deleted and host_deleted to simply be
May 3, 2018
ae17dfb
server: add user_deleted and host_deleted output files for db_dump.
May 3, 2018
b4f0bae
server: db_dump shouldn't export create_time for user_deleted or
May 3, 2018
bcd853b
web: implementation of wipe account
May 4, 2018
f868227
web/server: change primary key of user_deleted to userid and
May 7, 2018
cff14c4
Merge branch 'master' into knr_right_to_erase
May 7, 2018
ec98197
web: fix bug introduced during merge
May 7, 2018
4720ab7
web: fix issue with password hash caused by merge from master
May 7, 2018
fd25c43
server: change create_time on host_deleted and user_deleted to double
May 8, 2018
f551dd8
web/server: when a user deletes their account (wipe), set results in …
May 8, 2018
239af2d
Merge branch 'master' into knr_right_to_erase
May 15, 2018
53250e7
web: fix bug in change email where the reversal email was only sent to
May 15, 2018
2145371
web: don't allow a user to start the delete account process if their
May 15, 2018
328a901
db: add indexes in support delete account
May 16, 2018
f7e310e
server: Use mysql_store_result() instead of mysql_use_result() when
May 16, 2018
fdf493e
web: use sensible constant values for times in code (improve
May 16, 2018
7172942
web: reorganize code so that error_page is not called in inc files
May 16, 2018
f799c9c
web: fix issues identified by scruitinizer
May 16, 2018
7ce2370
db: change index names to not be shortened
May 17, 2018
ae72004
web: Make the delay after invalidating the autheniticator something that
May 17, 2018
b6804ab
web: add mising closing parenthesis
May 17, 2018
0c2b0bc
web: remove excess space
May 17, 2018
83ea2bc
web: fixing spacing identified by scruitinizer
May 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions db/boinc_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ void PLATFORM::clear() {memset(this, 0, sizeof(*this));}
void APP::clear() {memset(this, 0, sizeof(*this));}
void APP_VERSION::clear() {memset(this, 0, sizeof(*this));}
void USER::clear() {memset(this, 0, sizeof(*this));}
void USER_DELETED::clear() {memset(this, 0, sizeof(*this));}
void TEAM::clear() {memset(this, 0, sizeof(*this));}
void HOST::clear() {memset(this, 0, sizeof(*this));}
void HOST_DELETED::clear() {memset(this, 0, sizeof(*this));}
void RESULT::clear() {
memset(this, 0, sizeof(*this));
size_class = -1;
Expand Down Expand Up @@ -119,10 +121,14 @@ DB_APP_VERSION::DB_APP_VERSION(DB_CONN* dc) :
DB_BASE("app_version", dc?dc:&boinc_db){}
DB_USER::DB_USER(DB_CONN* dc) :
DB_BASE("user", dc?dc:&boinc_db){}
DB_USER_DELETED::DB_USER_DELETED(DB_CONN* dc) :
DB_BASE("user_deleted", dc?dc:&boinc_db){}
DB_TEAM::DB_TEAM(DB_CONN* dc) :
DB_BASE("team", dc?dc:&boinc_db){}
DB_HOST::DB_HOST(DB_CONN* dc) :
DB_BASE("host", dc?dc:&boinc_db){}
DB_HOST_DELETED::DB_HOST_DELETED(DB_CONN* dc) :
DB_BASE("host_deleted", dc?dc:&boinc_db){}
DB_WORKUNIT::DB_WORKUNIT(DB_CONN* dc) :
DB_BASE("workunit", dc?dc:&boinc_db){}
DB_CREDITED_JOB::DB_CREDITED_JOB(DB_CONN* dc) :
Expand Down Expand Up @@ -192,8 +198,10 @@ DB_ID_TYPE DB_PLATFORM::get_id() {return id;}
DB_ID_TYPE DB_APP::get_id() {return id;}
DB_ID_TYPE DB_APP_VERSION::get_id() {return id;}
DB_ID_TYPE DB_USER::get_id() {return id;}
DB_ID_TYPE DB_USER_DELETED::get_id() {return userid;}
DB_ID_TYPE DB_TEAM::get_id() {return id;}
DB_ID_TYPE DB_HOST::get_id() {return id;}
DB_ID_TYPE DB_HOST_DELETED::get_id() {return hostid;}
DB_ID_TYPE DB_WORKUNIT::get_id() {return id;}
DB_ID_TYPE DB_RESULT::get_id() {return id;}
DB_ID_TYPE DB_MSG_FROM_HOST::get_id() {return id;}
Expand Down Expand Up @@ -425,6 +433,21 @@ void DB_USER::db_parse(MYSQL_ROW &r) {
email_addr_change_time = atof(r[i++]);
}

void DB_USER_DELETED::db_print(char* buf){
sprintf(buf,
"public_cross_project_id=%s, create_time=%.15e",
public_cross_project_id, create_time
);
}

void DB_USER_DELETED::db_parse(MYSQL_ROW &r) {
int i=0;
clear();
userid = atol(r[i++]);
strcpy2(public_cross_project_id, r[i++]);
create_time = atof(r[i++]);
}

void DB_TEAM::db_print(char* buf){
ESCAPE(name);
ESCAPE(name_lc);
Expand Down Expand Up @@ -894,6 +917,21 @@ int DB_HOST::fpops_stddev(double& stddev) {
return db->get_double(query, stddev);
}

void DB_HOST_DELETED::db_print(char* buf){
sprintf(buf,
"public_cross_project_id=%s, create_time=%.15e",
public_cross_project_id, create_time
);
}

void DB_HOST_DELETED::db_parse(MYSQL_ROW &r) {
int i=0;
clear();
hostid = atol(r[i++]);
strcpy2(public_cross_project_id, r[i++]);
create_time = atof(r[i++]);
}

void DB_WORKUNIT::db_print(char* buf){
sprintf(buf,
"create_time=%d, appid=%lu, "
Expand Down
18 changes: 18 additions & 0 deletions db/boinc_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ class DB_USER : public DB_BASE, public USER {
void operator=(USER& r) {USER::operator=(r);}
};

class DB_USER_DELETED : public DB_BASE, public USER_DELETED {
public:
DB_USER_DELETED(DB_CONN* p=0);
DB_ID_TYPE get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(USER_DELETED& r) {USER_DELETED::operator=(r);}
};

class DB_TEAM : public DB_BASE, public TEAM {
public:
DB_TEAM(DB_CONN* p=0);
Expand All @@ -182,6 +191,15 @@ class DB_HOST : public DB_BASE, public HOST {
void operator=(HOST& r) {HOST::operator=(r);}
};

class DB_HOST_DELETED : public DB_BASE, public HOST_DELETED {
public:
DB_HOST_DELETED(DB_CONN* p=0);
DB_ID_TYPE get_id();
void db_print(char*);
void db_parse(MYSQL_ROW &row);
void operator=(HOST_DELETED& r) {HOST_DELETED::operator=(r);}
};

class DB_RESULT : public DB_BASE, public RESULT {
public:
DB_RESULT(DB_CONN* p=0);
Expand Down
14 changes: 14 additions & 0 deletions db/boinc_db_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ struct USER {
void clear();
};

struct USER_DELETED {
DB_ID_TYPE userid;
char public_cross_project_id[256];
double create_time;
void clear();
};

#define TEAM_TYPE_CLUB 1
#define TEAM_TYPE_COMPANY 2
#define TEAM_TYPE_PRIMARY 3
Expand Down Expand Up @@ -381,6 +388,13 @@ struct HOST {
bool get_opencl_cpu_prop(const char* platform, OPENCL_CPU_PROP&);
};

struct HOST_DELETED {
DB_ID_TYPE hostid;
char public_cross_project_id[256];
double create_time;
void clear();
};

// values for file_delete state
// see html/inc/common_defs.inc
#define FILE_DELETE_INIT 0
Expand Down
35 changes: 33 additions & 2 deletions db/constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ alter table result
-- scheduler (avoid sending mult results of same WU to one user)

alter table msg_from_host
add index message_handled (handled);
add index message_handled (handled),
-- for message handler
add index message_hostid(hostid);
-- for delete account

alter table msg_to_host
add index msg_to_host(hostid, handled);
Expand Down Expand Up @@ -114,7 +116,9 @@ alter table credited_job
add unique credited_job_user_wu (userid, workunitid);

alter table team_delta
add index team_delta_teamid (teamid, timestamp);
add index team_delta_teamid (teamid, timestamp),
add index team_delta_userid (userid);
-- for delete account

alter table team_admin
add unique (teamid, userid);
Expand Down Expand Up @@ -147,3 +151,30 @@ alter table credit_user
alter table credit_team
add index ct_total(appid, total),
add index ct_avg(appid, expavg);

alter table token
add index token_userid(userid);

alter table user_deleted
add index user_deleted_create(create_time);
-- for delete account

alter table host_deleted
add index host_deleted_create(create_time);
-- for delete account

alter table donation_paypal
-- for delete account
add index donation_paypal_userid(userid);

alter table banishment_vote
add index banishment_vote_userid(userid);
-- for delete account

alter table post_ratings
add index post_ratings_user(user);
-- for delete account

alter table sent_email
add index sent_email_userid(userid);
-- for delete account
18 changes: 16 additions & 2 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,20 @@ create table token (
type char not null,
create_time integer not null,
expire_time integer,
primary key (token),
index token_userid (userid)
primary key (token)
) engine=InnoDB;

create table user_deleted (
userid integer not null,
public_cross_project_id varchar(254) not null,
create_time double not null,
primary key (userid)
) engine=InnoDB;

create table host_deleted (
hostid integer not null,
public_cross_project_id varchar(254) not null,
create_time double not null,
primary key (hostid)
) engine=InnoDB;

55 changes: 55 additions & 0 deletions html/inc/boinc_db.inc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ class BoincTeamDelta {
$db = BoincDb::get();
return $db->enum('team_delta', 'BoincTeamDelta', $where_clause);
}
static function delete_for_user($user_id) {
$db = BoincDb::get();
return $db->delete_aux('team_delta', "userid=$user_id");
Copy link
Contributor

@brevilo brevilo May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an index on team_delta.userid to make this query efficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}
}

class BoincHost {
Expand Down Expand Up @@ -343,6 +347,10 @@ class BoincHost {
if (!$ret) return $ret;
return $db->insert_id();
}
static function delete_for_user($user_id) {
$db = BoincDb::get();
return $db->delete_aux('host', "userid=$user_id");
}
}

class BoincResult {
Expand Down Expand Up @@ -602,6 +610,10 @@ class BoincHostAppVersion {
$db = BoincDb::get();
return $db->update_aux('host_app_version', $clause);
}
static function delete_for_user($user_id) {
$db = BoincDb::get();
return $db->delete_aux('host_app_version', "host_id in (select id from host where userid = $user_id)");
}
}

// DB utility functions
Expand Down Expand Up @@ -823,6 +835,49 @@ class BoincToken {
return $db->affected_rows();
}

static function delete_for_user($user_id) {
$db = BoincDb::get();
$db->delete_aux('token', "userid=$user_id");
Copy link
Contributor

@brevilo brevilo May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an index on token.userid to make this query efficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userid has an index but it was defined in schema.sql. I've moved it to constraints.sql.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

return $db->affected_rows();
}

}

class BoincUserDeleted {

static function insert_user($user) {
$now = time();
$cpid = md5($user->cross_project_id.$user->email_addr);
$clause = "(userid, public_cross_project_id, create_time) values ($user->id, '$cpid', $now)";
$db = BoincDb::get();
return $db->insert('user_deleted', $clause);
}

static function delete_expired() {
$db = BoincDb::get();
$expire_time = time() - 60*86400; //60 days ago
$db->delete_aux('user_deleted', "create_time < $expire_time");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an index on user_deleted.create_time to make this query efficient (despite the expected low number of records).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return $db->affected_rows();
}

}

class BoincHostDeleted {

static function insert_hosts_for_user($user) {
$now = time();
$clause = "select id, host_cpid, $now from host where userid = $user->id";
$db = BoincDb::get();
return $db->insert('host_deleted', $clause);
}

static function delete_expired() {
$db = BoincDb::get();
$expire_time = time() - 60*86400; //60 days ago
$db->delete_aux('host_deleted', "create_time < $expire_time");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an index on host_deleted.create_time to make this query efficient (despite the expected low number of records).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return $db->affected_rows();
}

}


Expand Down
Loading