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

User Opt-in consent #2504

Merged
merged 78 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
23640e9
web: Add new tables to database.
May 4, 2018
0537feb
web: Add functionality of consent to Web site and RPCs.
May 4, 2018
49599f2
web ops: Add manage consent type page to HTML admin ops.
May 4, 2018
d433bed
web: Fixed bugs found by Scrutinizer.
May 8, 2018
6fa9a01
web: Add an opt-in consent form to login workflow.
May 8, 2018
0a046c1
web: Fixed bug found by Scrutinizer.
May 8, 2018
06e162e
web: added additional consent_type for data exports.
May 17, 2018
16846e4
web: Make sure that the terms of use file exists as well as opt-in co…
May 17, 2018
4ad801f
web: project privacy preferences modified to add 'consent to data exp…
May 17, 2018
039db25
Merge branch 'master' into sak-useroptin-dbaddconsent
May 17, 2018
07607ed
web: Fixed bug found by Scrutinizer.
May 17, 2018
284694c
web: Fixed bug, variable restored.
May 17, 2018
f6437a8
ops: If enable record consent is enabled, import team will not create…
May 18, 2018
a8d7be5
web: Misc minor changes.
May 22, 2018
4fa8a9f
web: Updated database, consent and consent_type tables.
May 24, 2018
35b446f
web: Update web RPCs to use new consent defintions.
May 24, 2018
cbd1b5c
web: added consent table to delete functionality.
May 24, 2018
2d4f9e4
web: updated form to use new consent table definitions
May 24, 2018
b0557ef
web: updated preferences for stats exports to use new consent table d…
May 24, 2018
0cd3aab
web: added error message when attempting to set unknown consent_type
May 24, 2018
d6dd094
web: Modified consent_type table with new fields.
Jun 1, 2018
a667059
web: modified manage consent type ops page to handle new fields in co…
Jun 1, 2018
1f70734
web: modified privacy prefs code
Jun 1, 2018
6482527
web: refactored code to remove config option enable_record_optin_consent
Jun 1, 2018
a96ed6b
web: modified RPCs to use new consent_type table definitions.
Jun 1, 2018
21b6c3e
web: modified team import to use check_consent_type function.
Jun 1, 2018
f172822
web: Exiting users agree to terms of use when logging in.
Jun 4, 2018
4e72cfa
web: removed commented-out code.
Jun 4, 2018
8944ba5
web: minor changes found in review
Jun 11, 2018
f1bff5b
db: fixed schema.sql bugs found in review.
Jun 11, 2018
f7332cc
web: Add new constant for terms of use file.
Jun 11, 2018
8e023cc
web: Replaced SESSION with temporary cookies.
Jun 11, 2018
cc6efac
db: Reorganize database changes, and add indices to new tables.
Jun 12, 2018
431d8d6
db: Modified database definitions for consent_type table.
Jun 15, 2018
ffdc327
web: Web code modified to work with new database table definitions.
Jun 15, 2018
71046d4
web: Fixed bug found in Scrutinizer.
Jun 15, 2018
74a5454
Modified variable 'protected' in consent_type table to be 'protectedc…
Aug 28, 2018
06ba429
db: Add consent_type table to C++ database API.
Aug 28, 2018
59697b7
db: Renamed database field 'protectedct' to 'protect'.
Aug 31, 2018
d094f16
web: renamed 'protectedct' field 'protect'.
Aug 31, 2018
20d195e
web: Fixed bug where disabled ENROLL consent_type still sent user to …
Sep 6, 2018
d924bb2
db: Add necessary DB_CONSENT_TYPE declarations to boinc_db
Sep 7, 2018
75d4716
db_dump changes - use consent_type table to dump user and host stats …
Sep 7, 2018
60acd8c
db: Fixed bug where STATSEXPORTS was spelled incorrectly.
Sep 12, 2018
60ee7e8
Changed/Fixed SQL queries. New queries now function to select users w…
Sep 12, 2018
c4c2ae6
Added additional index to consent table as well as foreign_key index.
Sep 12, 2018
3d91ec6
DB: move index from schema.sql to constraints.sql
ChristianBeer Sep 11, 2018
4e82939
Locale: extract strings from content.sql
ChristianBeer Sep 11, 2018
cbce74d
Merge branch 'master' into sak-useroptin-dbaddconsent
Sep 12, 2018
9593f18
Fixed missing comma
Sep 12, 2018
fd3fb65
fixed semicolons should be colons
Sep 12, 2018
4531d56
db: Update index for consent table
Sep 13, 2018
14fad89
db: Added SQL view to schema and db_update.php
Sep 13, 2018
1aa90e0
sched: Take advantage of SQL View lastest_consent in queries to user …
Sep 13, 2018
7bf7d5c
web: User SQL View latest_consent to obtain consent information for u…
Sep 13, 2018
e4df047
web: Misc small fixes.
Sep 17, 2018
4cb30b1
Removed unnecessary primary_key from insert statements.
Sep 17, 2018
90bdd91
web: defined CONSENT_TYPE_ENROLL and replaced string 'ENROLL' with th…
Sep 17, 2018
a02bc83
web: Modified lookup to also search fo consent_flag.
Sep 17, 2018
b44a8c8
db: Renamed database field 'protect' to 'project_specific'
Sep 17, 2018
992cece
web: Renamed database field 'protect' to 'project_specific'.
Sep 17, 2018
1381601
web: Replaced login_action code with a function that interecepts the …
Sep 17, 2018
41b8064
Added long docmentation about the create_account RPC, and what may ne…
Sep 17, 2018
a8e1862
rpc: Modified create_account RPC.
Sep 18, 2018
c38f806
sched: Use safe_str* functions.
Sep 20, 2018
683c562
web: Re-added line thaty was accidentally removed.
Sep 28, 2018
e37e599
rpc: Add check terms-of-use file when creating account.
Sep 28, 2018
759cc3f
Merge branch 'master' into sak-useroptin-dbaddconsent
Oct 1, 2018
5495802
rpc: Removed min_version_number code block.
Oct 5, 2018
7d7c187
ops: fixed insert statement to use all variables
Oct 22, 2018
0751f7f
db: Modified db_dump so user and host output is independent of stats_…
Oct 22, 2018
c817630
Merge branch 'master' into sak-useroptin-dbaddconsent
Oct 22, 2018
cd409c3
web rpc: add consent check to get_project config
Oct 23, 2018
0d52da9
modified db_dump to ignore users and hosts.
Oct 23, 2018
6135df9
db_dump: Modified code to fix SQL bug.
Oct 24, 2018
953dd47
ops: Removed delete functionality for consent_types.
Oct 25, 2018
096fde1
db: explicit add of delete restrict
Oct 25, 2018
01ed6b7
ops: remove mct_delete function
Oct 25, 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
24 changes: 24 additions & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,27 @@ create table host_deleted (
primary key (hostid)
) engine=InnoDB;

create table consent (
id integer not null auto_increment,
userid integer not null,
consent_name varchar(255) not null,
consent_time integer not null,
consent_flag tinyint not null,
consent_not_required tinyint not null,
source varchar(255) not null,
primary key (id)
) engine=InnoDB;

create table consent_type (
consent_id integer not null auto_increment,
shortname varchar(255) not null,
description varchar(255) not null,
enabled integer not null,
protected integer not null,
privacypref integer not null,
primary key (consent_id)
) engine=InnoDB;

insert into consent_type (consent_id, shortname, description, enavled, protected, privacypref)
Copy link
Member

Choose a reason for hiding this comment

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

enavled should be enabled.

Copy link
Member

Choose a reason for hiding this comment

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

Also the whole insert query should be:
insert into consent_type (consent_id, shortname, description, enabled, protected, privacypref)
values (1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 0),
(2, 'STATSEXPORT', 'Do you consent to exporting your data to BOINC statistics aggregation Web sites?', 0, 1, 1);

values (1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 0);
values (2, 'STATSEXPORT', 'Do you consent to exporting your data to BOINC statistics aggregation Web sites?', 0, 1, 1);
Copy link
Member

Choose a reason for hiding this comment

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

@davidpanderson - where is the best place to put default content that needs to be inserted into tables? Should this be part of make or update project?

Copy link
Member

Choose a reason for hiding this comment

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

@davidpanderson I see that this content is included in db_update for existing projects. However, for new projects, how should tables be populated with default content?

Copy link
Member

Choose a reason for hiding this comment

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

Also - the insert query should be this:

insert into consent_type (consent_id, shortname, description, enabled, protected, privacypref)
values (1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 0), (2, 'STATSEXPORT', 'Do you consent to exporting your data to BOINC statistics aggregation Web sites?', 0, 1, 1);

43 changes: 43 additions & 0 deletions html/inc/account.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
// - forms for create / login
// - function to make login token

include_once("../inc/consent.inc");

// If have recent token, return it.
// Else make login token, store in user record, return token
//
Expand Down Expand Up @@ -113,6 +115,23 @@ function create_account_form($teamid, $next_url) {
"postal_code"
);
}

// Add terms of use to Web form. User must agree by checking the checkbox.
$tou_file = "../../terms_of_use.txt";
drshawnkwang marked this conversation as resolved.
Show resolved Hide resolved
if ( check_consent_type('ENROLL') and file_exists($tou_file) ) {
$terms_of_use = trim(file_get_contents($tou_file));
if ($terms_of_use) {
panel('Terms of Use', function() use($terms_of_use) {
drshawnkwang marked this conversation as resolved.
Show resolved Hide resolved
echo nl2br($terms_of_use);
}
);
$myitems = array(
array("agree_to_terms_of_use", "", false),
);
form_checkboxes(tra("Do you agree to the terms of use above?"), $myitems, 'tabindex="0"');
}
}

}

function login_form($next_url) {
Expand Down Expand Up @@ -140,4 +159,28 @@ function login_form($next_url) {
form_end();
}

function user_agreetermsofuse_form($next_url) {
form_start(secure_url_base()."/user_agreetermsofuse_action.php", "post");
form_input_hidden("next_url", $next_url);

$tou_file = "../../terms_of_use.txt";
drshawnkwang marked this conversation as resolved.
Show resolved Hide resolved
$terms_of_use = trim(file_get_contents($tou_file));
if ($terms_of_use) {
panel('Terms of Use', function() use($terms_of_use) {
echo nl2br($terms_of_use);
}
);
$myitems = array(
array("agree_to_terms_of_use", "", false),
);
form_checkboxes(tra("Do you agree to the terms of use above?"), $myitems, 'tabindex="0"');
}
else {
// error - no terms of use for user to agree to!
}

form_submit("I agree");
drshawnkwang marked this conversation as resolved.
Show resolved Hide resolved
form_end();
}

?>
66 changes: 66 additions & 0 deletions html/inc/boinc_db.inc
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,72 @@ class BoincHostDeleted {

}

class BoincConsent {
static function lookup($clause) {
$db = BoincDb::get();
return $db->lookup('consent', 'BoincConsent', $clause);
}

static function enum($where_clause) {
$db = BoincDb::get();
return $db->enum('consent', 'BoincConsent', $where_clause);
}

static function insert ($clause) {
$db = BoincDb::get();
return $db->insert('consent', $clause);
}

static function update ($clause) {
$db = BoincDb::get();
return $db->update_aux('consent', $clause);
}

static function delete($clause) {
$db = BoincDb::get();
return $db->delete_aux('consent', $clause);
}

static function delete_for_user($user_id) {
$db = BoincDb::get();
$db->delete_aux('consent', "userid=$user_id");
return $db->affected_rows();
}

}

class BoincConsentType {
static function lookup($clause) {
$db = BoincDb::get();
return $db->lookup('consent_type', 'BoincConsentType', $clause);
}

static function enum($where_clause, $order_clause=null) {
$db = BoincDb::get();
return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause);
}

static function insert ($clause) {
$db = BoincDb::get();
return $db->insert('consent_type', $clause);
}

static function update ($clause) {
$db = BoincDb::get();
return $db->update_aux('consent_type', $clause);
}

function delete() {
$db = BoincDb::get();
return $db->delete($this, 'consent_type');
}

function delete_aux($clause) {
$db = BoincDb::get();
return $db->delete_aux('consent_type', $clause);
}

}

// DEPRECATED: use BoincDb::escape_string where possible
//
Expand Down
70 changes: 70 additions & 0 deletions html/inc/consent.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2017 University of California
Copy link
Member

Choose a reason for hiding this comment

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

copyright should be 2018

//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.

// functions dealing with the consent and consent_type tables.

include_once("../inc/boinc_db.inc");
include_once("../inc/util.inc");

function consent_to_a_policy($user, $consent_name, $consent_flag, $consent_not_required, $source, $ctime = 0) {
$myn = BoincDb::escape_string($consent_name);
$mys = BoincDb::escape_string($source);
if ($ctime==0) {
$mytime = $user->create_time;
}
else {
$mytime = $ctime;
}
return BoincConsent::insert(
"(id, userid, consent_name, consent_time, consent_flag, consent_not_required, source) " .
"values(0, $user->id, '$myn', $mytime, $consent_flag, $consent_not_required, '$mys')"
);

}

function consent_after_login($user, $perm=true, $next_url = "") {
session_start();
$_SESSION['user'] = $user;
$_SESSION['perm'] = $perm;
drshawnkwang marked this conversation as resolved.
Show resolved Hide resolved
$save_url = $next_url;
$consent_result = BoincConsent::lookup("userid={$user->id} AND consent_name='ENROLL' ORDER BY consent_time DESC LIMIT 1");
if ($consent_result) {
if ($consent_result->consent_flag != 1) {
$next_url = "user_agreetermsofuse.php?next_url=$save_url";
}
else{
send_cookie('auth', $user->authenticator, $perm);
session_unset();
session_destroy();
}
}
else {
$next_url = "user_agreetermsofuse.php?next_url=$save_url";
}
return $next_url;
}

// Checks to see if a particular consent_type name is in available and
// enabled.
function check_consent_type($name) {
$ct = BoincConsentType::lookup("shortname = '{$name}'");
if ($ct and ($ct->enabled)) {
return TRUE;
}
return FALSE;
}
1 change: 1 addition & 0 deletions html/inc/delete_account.inc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function wipe_account($user) {

BoincHostAppVersion::delete_for_user($user->id);
BoincHost::delete_for_user($user->id);
BoincConsent::delete_for_user($user->id);

// final action
delete_user($user); //from user_util.inc
Expand Down
2 changes: 1 addition & 1 deletion html/inc/prefs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function print_prefs_form(
prefs_form_project($prefs, $error);
if (!$venue) {
prefs_form_privacy($user);
venue_form($user);
prefs_form_consent($user);
}
prefs_form_project_specific($prefs->project_specific, $project_error);
}
Expand Down
45 changes: 45 additions & 0 deletions html/inc/prefs_project.inc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ $privacy_pref_descs = array (
),
);

// Privacy preferences located in consent_type table. Loop over the
// table and extract those consent types with enabled=1 and
// privacypref=1.
$privacy_consent_descs = array();
$_consenttypes = BoincConsentType::enum("enabled=1 AND privacypref=1", "ORDER BY protected DESC");
foreach ($_consenttypes as $ct) {
$privacy_consent_descs[] = new PREF_CONSENT(
tra($ct->description),
tra($ct->description),
"consent_".urlencode($ct->shortname),
$ct->shortname,
0
);
}

global $text;
global $parse_result;
global $top_parse_result;
Expand Down Expand Up @@ -254,6 +269,19 @@ function prefs_show_privacy($user, $columns) {
}
}

function prefs_show_consent($user, $columns) {
global $privacy_consent_descs;
if ($columns) {
foreach ($privacy_consent_descs as $p) {
$p->consent_show_cols($user);
}
} else {
foreach ($privacy_consent_descs as $p) {
$p->consent_show($user);
}
}
}

function prefs_show_project_specific($prefs, $columns=false) {
if ($columns) {
$project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
Expand Down Expand Up @@ -287,6 +315,7 @@ function print_prefs_display_project($user, $columns=false) {
}
prefs_show_project($project_prefs, false);
prefs_show_privacy($user, false);
prefs_show_consent($user, false);
venue_show($user);
prefs_show_project_specific($project_prefs, false);
$tokens = url_tokens($user->authenticator);
Expand All @@ -311,6 +340,13 @@ function prefs_form_privacy($user) {
}
}

function prefs_form_consent($user) {
global $privacy_consent_descs;
foreach ($privacy_consent_descs as $p) {
$p->consent_show_form_row($user, false);
}
}

function prefs_form_project($prefs, $error=false) {
global $project_pref_descs;
foreach ($project_pref_descs as $p) {
Expand Down Expand Up @@ -341,6 +377,15 @@ function prefs_privacy_parse_form(&$user) {
return $error;
}

function prefs_consent_parse_update(&$user) {
global $privacy_consent_descs;
$error = false;
foreach ($privacy_consent_descs as $p) {
$p->parse_form($user, $error);
}
return $error;
}

// Parse the project specific prefs form.
// For details see project/project_specific_prefs.inc
//
Expand Down
Loading