mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Merge pull request #1266 from RaspAP/feat/webauth
Add auth_enabled option to config
This commit is contained in:
commit
eb0d8bfa76
2 changed files with 17 additions and 12 deletions
|
@ -29,10 +29,13 @@ define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf');
|
|||
define('RASPI_ACCESS_CHECK_IP', '1.1.1.1');
|
||||
define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one');
|
||||
|
||||
// Constant for the 5GHz wireless regulatory domain
|
||||
// Constants for the 5GHz wireless regulatory domain.
|
||||
define('RASPI_5GHZ_ISO_ALPHA2', array('NL','US'));
|
||||
define('RASPI_5GHZ_MAX_CHANNEL', 165);
|
||||
|
||||
// Enable basic authentication for the web admin.
|
||||
define('RASPI_AUTH_ENABLED', true);
|
||||
|
||||
// Optional services, set to true to enable.
|
||||
define('RASPI_WIFICLIENT_ENABLED', true);
|
||||
define('RASPI_HOTSPOT_ENABLED', true);
|
||||
|
|
|
@ -5,16 +5,18 @@ $pass = $_SERVER['PHP_AUTH_PW'] ?? "";
|
|||
require_once RASPI_CONFIG.'/raspap.php';
|
||||
$config = getConfig();
|
||||
|
||||
$validated = ($user == $config['admin_user']) && password_verify($pass, $config['admin_pass']);
|
||||
|
||||
if (!$validated) {
|
||||
header('WWW-Authenticate: Basic realm="RaspAP"');
|
||||
if (function_exists('http_response_code')) {
|
||||
// http_response_code will respond with proper HTTP version back.
|
||||
http_response_code(401);
|
||||
} else {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
if (RASPI_AUTH_ENABLED) {
|
||||
$validated = ($user == $config['admin_user']) && password_verify($pass, $config['admin_pass']);
|
||||
if (!$validated) {
|
||||
header('WWW-Authenticate: Basic realm="RaspAP"');
|
||||
if (function_exists('http_response_code')) {
|
||||
// http_response_code will respond with proper HTTP version back.
|
||||
http_response_code(401);
|
||||
} else {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
}
|
||||
exit('Not authorized'.PHP_EOL);
|
||||
}
|
||||
|
||||
exit('Not authorized'.PHP_EOL);
|
||||
} else {
|
||||
$validated = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue