Skip to content

Commit 11bd2ea

Browse files
authored
Merge pull request #8 from femto-code/require-auth
Authorization
2 parents 632ab03 + 8b14f6e commit 11bd2ea

File tree

6 files changed

+181
-36
lines changed

6 files changed

+181
-36
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
Open for your feature [requests](https://github.com/femto-code/Rasberry-Pi-Dashboard/pulls) or [issues](https://github.com/femto-code/Rasberry-Pi-Dashboard/issues)!
88
[https://github.com/femto-code/Rasberry-Pi-Dashboard](https://github.com/femto-code/Rasberry-Pi-Dashboard)
99

10+
## [0.4] - 2020-08-XX
11+
- new authorization/login modal to secure dashboard
12+
1013
## [0.3] - 2020-07-10
1114
- new loading screen
1215
- small design adjustments

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
## Features
99

1010
- Live surveillance of RPi hardware (CPU Temperature, frequency, loads etc.)
11+
- Protected access with password login (default: root) ([configure password](https://github.com/femto-code/Rasberry-Pi-Dashboard#configure-password))
1112
- State Mail to send an email containing a summary
1213
- Power (shutdown/reboot) Raspberry Pi with schedule options ([setup instructions](https://github.com/femto-code/Rasberry-Pi-Dashboard#setup-project))
1314
- Web-App capable with mobile integration thanks to responsive design
@@ -36,6 +37,13 @@
3637
- Open web browser with URL: `http://IP_OF_YOUR_RPI/Raspberry-Pi-Dashboard`
3738
- [OPTIONAL] rename the folder to shorten the address input: `mv /var/www/html/Raspberry-Pi-Dashboard /var/www/html/{subfolder_name}` (Note: replace {subfolder_name} with your wish to enter the web page)
3839

40+
### Configure password
41+
42+
>You should change the default password (which is **root**) and a choose a more secure one by following these steps:
43+
1. Go to [https://www.md5-generator.de/](https://www.md5-generator.de/) and generate the MD5 encyrpted passphrase.
44+
2. Open `serv.php` on line 7 and adjust the passphrase with the generated one from step 1.
45+
3. Remember password and enjoy!
46+
3947
### Enabling remote shutdown/reboot (OPTIONAL)
4048
> Recommended only, if your RPi is not accessible over the Internet!
4149
In order to use the remote power functionality you have to give the user `www-data` advanced rights:

backend/serv.php

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
<?php
2+
session_start();
23
error_reporting (E_ALL);
34
ini_set ('display_errors', 'On');
5+
6+
// Change password here as MD5 encryption
7+
$correctPassword = "63a9f0ea7bb98050796b649e85481845";
8+
9+
if(isset($_GET["logout"])){
10+
session_destroy();
11+
exit();
12+
}
13+
if(isset($_POST["login"])){
14+
if(isset($_POST["pw"])){
15+
$pw=md5($_POST["pw"]);
16+
if($pw==$correctPassword){
17+
echo "correctCredentials";
18+
$_SESSION["rpidbauth"]="1";
19+
}else{
20+
echo "wrongCredentials";
21+
}
22+
}
23+
exit();
24+
}
425
if(isset($_GET["checkShutdown"])){
526
system("date --date @$(head -1 /run/systemd/shutdown/scheduled |cut -c6-15)");
627
exit;

backend/sys_infos.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?php
22
error_reporting(E_ALL);
33
ini_set ('display_errors', 'On');
4+
// Authorization
5+
session_start();
6+
if(!isset($_SESSION["rpidbauth"])){
7+
$output = array('auth' => 'false');
8+
echo json_encode($output);
9+
exit();
10+
}
411
// Uptime
512
$uptime = shell_exec("cat /proc/uptime");
613
$uptime = explode(" ", $uptime);
@@ -127,7 +134,7 @@
127134
echo $ausgabe;
128135

129136
}else{
130-
$output = array('timest' => $timed, 'uptime' => $uptime_string, 'cputemp' => $cputemp, 'cpufreq' => $cpufreq, 'load' => $getLoad, 'memperc' => $memperc, 'memavail' => $mavail, 'memunavail' => $munavail, 'swapperc' => $swapperc, 'swaptotal' => $swaptotal, 'swapused' => $swapused);
137+
$output = array('auth' => 'true', 'timest' => $timed, 'uptime' => $uptime_string, 'cputemp' => $cputemp, 'cpufreq' => $cpufreq, 'load' => $getLoad, 'memperc' => $memperc, 'memavail' => $mavail, 'memunavail' => $munavail, 'swapperc' => $swapperc, 'swaptotal' => $swaptotal, 'swapused' => $swapused);
131138
echo json_encode($output);
132139
}
133140

custom/custom.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ warn_loads_size = 2;
2020

2121
//***************************
2222
// DO NOT CHANGE
23-
console.log("Übernehme Userdaten: warncputemp="+warn_cpu_temp+" | warn_ram_space="+warn_ram_space+" | upd_time_interval="+upd_time_interval+" | warn_loads_size="+warn_loads_size);
23+
console.log("Custom user options: warncputemp="+warn_cpu_temp+" | warn_ram_space="+warn_ram_space+" | upd_time_interval="+upd_time_interval+" | warn_loads_size="+warn_loads_size);

0 commit comments

Comments
 (0)