core/source/overwrites/auths/basic.php

75 lines
1.2 KiB
PHP
Raw Normal View History

2025-09-09 12:07:53 +02:00
<?php
2025-09-16 12:05:35 +02:00
namespace davina\overwrites;
2025-09-09 12:07:53 +02:00
require_once('vendor/autoload.php');
2025-09-16 12:48:45 +02:00
require_once(DIR_LOGIC . '/base.php');
require_once(DIR_LOGIC . '/sources/_interface.php');
2025-09-09 12:07:53 +02:00
/**
*/
class class_auth_backend_basic
extends \Sabre\DAV\Auth\Backend\AbstractBasic
implements \Sabre\DAV\Auth\Backend\BackendInterface
{
/**
2025-09-21 13:27:37 +02:00
* @var array {list<\davina\sources\interface_source>}
2025-09-09 12:07:53 +02:00
*/
2025-09-21 13:27:37 +02:00
private array $sources;
2025-09-09 12:07:53 +02:00
/**
*/
public function __construct(
2025-09-21 13:27:37 +02:00
array $sources
2025-09-09 12:07:53 +02:00
)
{
// parent::__construct();
2025-09-21 13:27:37 +02:00
$this->sources = $sources;
2025-09-16 12:05:35 +02:00
$this->setRealm('davina');
2025-09-09 12:07:53 +02:00
}
/**
*/
protected function validateUserPass(
2025-09-21 13:27:37 +02:00
/*string */$identifier,
2025-09-09 12:07:53 +02:00
/*string */$password
)/* : bool*/
{
2025-09-21 13:27:37 +02:00
$parts = \explode('-', $identifier, 2);
$source_name = $parts[0];
$username = (
(\count($parts) >= 2)
?
$parts[1]
:
$source_name
);
2025-09-10 15:03:44 +02:00
$parameters = [
'username' => $username,
'password' => $password,
];
2025-09-21 13:27:37 +02:00
if (! \array_key_exists($source_name, $this->sources))
{
return false;
}
else
{
$source = $this->sources[$source_name];
/**
* @todo check for security
*/
\davina\set_parameters($parameters);
$data = $source->read(/*$parameters*/[]);
return ($data !== null);
}
2025-09-09 12:07:53 +02:00
}
}
?>