e214751ec30f5cdbf1b1341b5f9ea3856175420f
[ga4php.git] / authserver / www / admin.php
1 <?php
2 /*
3  * This is the web component of the GA4PHP radius server. This web app should be able to configure freeradius and itself.
4  * 
5  * This app will try to do the following:
6  * 1) initialise tokens
7  * 2) pull accounts from some backend (such as AD)
8  * 3) allow users to self-enroll.
9  * 
10  * I wonder if we can store data in the backend database itself? that would be interesting
11  * then user admin would be less disconnected. I.e. if a user was deleted from AD, their token
12  * data should disappear with them.
13  */
14 require_once("admin_actions.php");
15
16 // the logged in component
17 if($loggedin) {
18 ?>
19 <h1>GAAS Manager</h1>
20 Welcome to the Google Authenticator Authentication Server Manager Application<br>
21 <hr><h2>Users</h2>
22 <table border="1">
23 <tr><th>Username</th><th>RealName</th><th>Has Password?</th><th>Has Token?</th><th>One Time Key</th><th>Update</th><th>Delete</th></tr>
24 <?php
25 $users = $myAC->getUsers();
26 foreach($users as $user) {
27         $username = $user["username"];
28         
29         if($user["realname"] == "") $realname = "";
30         else $realname = $user["realname"];
31         
32         if($user["haspass"]) $haspass = "Yes <input type=\"password\" name=\"password\"> <a href=\"?action=deletepass&username=$username\">Delete Password</a>";
33         else $haspass = "No <input type=\"password\" name=\"password\">";
34         
35         if($user["hastoken"]) $hastoken = "Yes";
36         else $hastoken = "No";
37         
38         if($user["otk"]!="") $otk = "<a href=\"?action=getotk&username=$username&otk=".$user["otk"]."\">Get</a>";
39         else $otk = "Already Claimed";
40         
41         $delete = "<a href=\"?action=delete&username=$username\">Delete</a>";
42         
43         echo "<form method=\"post\" action=\"?action=update&username=$username\"><tr><td>$username</td><td><input type=\"text\" name=\"realname\" value=\"$realname\"></td><td>$haspass</td>";
44         echo "<td>$hastoken</td><td>$otk</td><td><input type=\"submit\" value=\"Update\"></td><td>$delete</td><tr></form>";
45
46 ?>
47 </table><br>
48 <form method="post" action="?action=createuser">Create User(s) - Enter a comma seperated list of names: <input type="text" name="username" size="120"> <input type="submit" value="Create"></form>
49
50 <?php
51 if(isset($_REQUEST["action"])) if($_REQUEST["action"] == "getotk") {
52         $username = $_REQUEST["username"];
53         $otk = $_REQUEST["otk"];
54         echo "<hr>Got One Time Key for user $username, this one-time-key can only be retrieved once, after that it is deleted<br>";
55         echo "<img src=\"?action=getotkimg&username=$username&otk=$otk\" alt=\"one time key error\"><br>";
56
57
58 ?>
59 <hr><h2>Radius Clients</h2>
60 Not yet implemented
61
62 <hr><a href="?action=logout">Logout</a>
63
64 <?php 
65
66
67 } else {
68         
69         
70         
71         
72         
73         
74         
75         
76         
77         
78         // Login page
79 ?>
80 <h1>GAAS Manager Login</h1>
81 <?php
82 if(isset($_REQUEST["message"])) {
83         echo "<font color=\"red\">Login Failed</font>";
84
85 ?>
86 <form method="post" action="?action=login">
87 <table>
88 <tr><td>Username</td><td><input type="text" name="username"></td></tr>
89 <tr><td>Password</td><td><input type="password" name="password"></td></tr>
90 <tr><td><input type="submit" value="Go"></td></tr>
91 </table>
92 </form>
93 <?php
94 }
95 ?>