mirror of
https://github.com/kd2org/picodav.git
synced 2024-11-16 16:48:26 +01:00
Fix handling of auth
FossilOrigin-Name: 3e8827ba0e8864d3a650f720880d5208372b0b55e5d62af476d9eb7f17dbe6c0
This commit is contained in:
parent
e47b150805
commit
bddfb63098
2 changed files with 4 additions and 12 deletions
10
index.php
10
index.php
|
@ -1786,7 +1786,7 @@ namespace PicoDAV
|
||||||
|
|
||||||
public function route(?string $uri = null): bool
|
public function route(?string $uri = null): bool
|
||||||
{
|
{
|
||||||
if (!ANONYMOUS_WRITE && !ANONYMOUS_READ) {
|
if (!ANONYMOUS_WRITE && !ANONYMOUS_READ && !$this->storage->auth()) {
|
||||||
$this->requireAuth();
|
$this->requireAuth();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1796,10 +1796,6 @@ namespace PicoDAV
|
||||||
|
|
||||||
protected function requireAuth(): void
|
protected function requireAuth(): void
|
||||||
{
|
{
|
||||||
if ($this->storage->auth()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
header('WWW-Authenticate: Basic realm="Please login"');
|
header('WWW-Authenticate: Basic realm="Please login"');
|
||||||
echo '<h2>Error 401</h2><h1>You need to login to access this.</h1>';
|
echo '<h2>Error 401</h2><h1>You need to login to access this.</h1>';
|
||||||
|
@ -1867,11 +1863,11 @@ RewriteRule ^.*$ /index.php [END]
|
||||||
$fp = fopen(__FILE__, 'r');
|
$fp = fopen(__FILE__, 'r');
|
||||||
|
|
||||||
if ($relative_uri == '.webdav/webdav.js') {
|
if ($relative_uri == '.webdav/webdav.js') {
|
||||||
fseek($fp, 50046, SEEK_SET);
|
fseek($fp, 50022, SEEK_SET);
|
||||||
echo fread($fp, 27769);
|
echo fread($fp, 27769);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fseek($fp, 50046 + 27769, SEEK_SET);
|
fseek($fp, 50022 + 27769, SEEK_SET);
|
||||||
echo fread($fp, 6988);
|
echo fread($fp, 6988);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -510,7 +510,7 @@ namespace PicoDAV
|
||||||
|
|
||||||
public function route(?string $uri = null): bool
|
public function route(?string $uri = null): bool
|
||||||
{
|
{
|
||||||
if (!ANONYMOUS_WRITE && !ANONYMOUS_READ) {
|
if (!ANONYMOUS_WRITE && !ANONYMOUS_READ && !$this->storage->auth()) {
|
||||||
$this->requireAuth();
|
$this->requireAuth();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -520,10 +520,6 @@ namespace PicoDAV
|
||||||
|
|
||||||
protected function requireAuth(): void
|
protected function requireAuth(): void
|
||||||
{
|
{
|
||||||
if ($this->storage->auth()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
header('WWW-Authenticate: Basic realm="Please login"');
|
header('WWW-Authenticate: Basic realm="Please login"');
|
||||||
echo '<h2>Error 401</h2><h1>You need to login to access this.</h1>';
|
echo '<h2>Error 401</h2><h1>You need to login to access this.</h1>';
|
||||||
|
|
Loading…
Reference in a new issue