mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-21 19:24:47 +02:00
refactor: general code base refactor (#2950)
* refactor * fix: bug in previous refactor * chore: exclude phpcompat sniff due to bug in phpcompat * fix: do not leak absolute paths * refactor/fix: batch extensions checking, fix DOS issue
This commit is contained in:
parent
b042412416
commit
2bbce8ebef
45 changed files with 679 additions and 827 deletions
42
lib/AuthenticationMiddleware.php
Normal file
42
lib/AuthenticationMiddleware.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
||||
* Atom feeds for websites that don't have one.
|
||||
*
|
||||
* For the full license information, please view the UNLICENSE file distributed
|
||||
* with this source code.
|
||||
*
|
||||
* @package Core
|
||||
* @license http://unlicense.org/ UNLICENSE
|
||||
* @link https://github.com/rss-bridge/rss-bridge
|
||||
*/
|
||||
|
||||
final class AuthenticationMiddleware
|
||||
{
|
||||
public function __invoke(): void
|
||||
{
|
||||
$user = $_SERVER['PHP_AUTH_USER'] ?? null;
|
||||
$password = $_SERVER['PHP_AUTH_PW'] ?? null;
|
||||
|
||||
if ($user === null || $password === null) {
|
||||
$this->renderAuthenticationDialog();
|
||||
exit;
|
||||
}
|
||||
if (
|
||||
Configuration::getConfig('authentication', 'username') === $user
|
||||
&& Configuration::getConfig('authentication', 'password') === $password
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$this->renderAuthenticationDialog();
|
||||
exit;
|
||||
}
|
||||
|
||||
private function renderAuthenticationDialog(): void
|
||||
{
|
||||
http_response_code(401);
|
||||
header('WWW-Authenticate: Basic realm="RSS-Bridge"');
|
||||
print render('error.html.php', ['message' => 'Please authenticate in order to access this instance !']);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue