This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
rangitaki/rcc/api/auth/auth.php
Marcel Kapfer (mmk2410) 5e45579ef1 Switch to HTTP Basic Auth
Resolves T115
2016-05-17 22:36:26 +02:00

22 lines
575 B
PHP

<?php
// Marcel Kapfer (mmk2410)
// License: MIT License
// HTTP Basic Auth for the API
$basedir = "../../../";
require '../../ssl.php';
require '../../password.php';
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="RCC API"');
header('HTTP/1.1 401 Unauthorized');
echo "Access denied to the RCC API!";
exit;
} elseif ($_SERVER['PHP_AUTH_USER'] != $username ||
!password_verify($_SERVER['PHP_AUTH_PW'], $password)) {
header('HTTP/1.1 401 Unauthorized');
echo "Wrong credentials: Access denied!";
exit;
}