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 "