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

23 lines
575 B
PHP
Raw Permalink Normal View History

2016-04-18 17:30:12 +02:00
<?php
// Marcel Kapfer (mmk2410)
// License: MIT License
// HTTP Basic Auth for the API
2016-04-18 17:30:12 +02:00
$basedir = "../../../";
2016-04-18 17:30:12 +02:00
require '../../ssl.php';
2016-04-18 17:30:12 +02:00
require '../../password.php';
2016-04-18 17:30:12 +02:00
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="RCC API"');
2016-04-18 17:30:12 +02:00
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;
2016-04-18 17:30:12 +02:00
}