From c456e6e3f758fbf578b97aec284bebfbde5cb6b7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 30 Apr 2018 17:58:34 +0300 Subject: [PATCH] HS 2.0: Terms and Conditions server and management Add minimal Terms and Conditions server for testing purposes. This can be used to test user interaction for Terms and Conditions acceptance. Signed-off-by: Jouni Malinen --- hs20/server/hs20-osu-server.txt | 6 ++++ hs20/server/www/config.php | 2 ++ hs20/server/www/terms.php | 49 +++++++++++++++++++++++++++++++++ hs20/server/www/users.php | 14 +++++++++- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 hs20/server/www/terms.php diff --git a/hs20/server/hs20-osu-server.txt b/hs20/server/hs20-osu-server.txt index 9c63da24b..70f13135e 100644 --- a/hs20/server/hs20-osu-server.txt +++ b/hs20/server/hs20-osu-server.txt @@ -95,6 +95,12 @@ sqlite3 /home/user/hs20-server/AS/DB/eap_user.db < sql-example.txt # the examples as-is for initial testing). cp -r www /home/user/hs20-server +# Create /home/user/hs20-server/terms-and-conditions file (HTML segment to be +# inserted within the BODY section of the page). +cat > /home/user/hs20-server/terms-and-conditions <Terms and conditions..

+EOF + # Build local keys and certs cd ca # Display help options. diff --git a/hs20/server/www/config.php b/hs20/server/www/config.php index e3af43504..830aa931f 100644 --- a/hs20/server/www/config.php +++ b/hs20/server/www/config.php @@ -1,4 +1,6 @@ diff --git a/hs20/server/www/terms.php b/hs20/server/www/terms.php new file mode 100644 index 000000000..99747a295 --- /dev/null +++ b/hs20/server/www/terms.php @@ -0,0 +1,49 @@ +prepare("SELECT identity FROM pending_tc WHERE mac_addr=?"); +$res->execute(array($addr)); +$row = $res->fetch(); +if (!$row) { + die("No pending session for the specified MAC address"); +} +$identity = $row[0]; +?> + +HS 2.0 Terms and Conditions + + +Accept the following terms and conditions by clicking here: Accept

\n
\n"; + readfile($t_c_file); +} else { + $res = $db->prepare("UPDATE users SET t_c_timestamp=? WHERE identity=?"); + if (!$res->execute(array($t_c_timestamp, $identity))) { + echo "

Failed to update user account.

"; + } else { + $res = $db->prepare("DELETE FROM pending_tc WHERE mac_addr=?"); + $res->execute(array($addr)); + + echo "

Terms and conditions were accepted.

"; + } +} + +?> + + + diff --git a/hs20/server/www/users.php b/hs20/server/www/users.php index c340a33e7..c2653727c 100644 --- a/hs20/server/www/users.php +++ b/hs20/server/www/users.php @@ -107,6 +107,10 @@ if ($cmd == "set-osu-cred" && $id > 0) { $db->exec("UPDATE users SET osu_user='$osu_user', osu_password='$osu_password' WHERE rowid=$id"); } +if ($cmd == 'clear-t-c' && $id > 0) { + $db->exec("UPDATE users SET t_c_timestamp=NULL WHERE rowid=$id"); +} + $dump = 0; if ($id > 0) { @@ -234,6 +238,13 @@ echo "password: \n"; echo "\n"; echo "\n"; +if (strlen($row['t_c_timestamp']) > 0) { + echo "
\n"; + echo "Clear Terms and Conditions acceptance
\n"; +} + echo "
\n"; $user = $row['identity']; @@ -303,7 +314,7 @@ echo "[Eventlog] "; echo "
\n"; echo "\n"; -echo "
UserRealmRemediationPolicyAccount typePhase 2 method(s)DevId\n"; +echo "
UserRealmRemediationPolicyAccount typePhase 2 method(s)DevIdT&C\n"; $res = $db->query('SELECT rowid,* FROM users WHERE phase2=1'); foreach ($res as $row) { @@ -338,6 +349,7 @@ foreach ($res as $row) { break; } } + echo "" . $row['t_c_timestamp']; echo "\n"; } echo "
\n";