102 lines
2.1 KiB
PHP
102 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace alveolata\auth;
|
||
|
|
||
|
require_once(DIR_ALVEOLATA . '/auth/abstract/interface-client.php');
|
||
|
require_once(DIR_ALVEOLATA . '/auth/implementation-srp/functions-client.php');
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
class implementation_client_srp implements interface_client
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* @param function<tuple<>,string> $generate_salt
|
||
|
* @param function<tuple<string,string,string>,void> $registration_send
|
||
|
* @param function<tuple<string,string>,record<passed:boolean,salt:string,b_value:string>> $login_handle1
|
||
|
* @param function<tuple<string>,record<passed:boolean,m2_server:string>> $login_handle2
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function __construct(
|
||
|
struct_srp_subject $subject,
|
||
|
\Closure $generate_salt,
|
||
|
\Closure $register_handle,
|
||
|
\Closure $login_handle1,
|
||
|
\Closure $login_handle2
|
||
|
)
|
||
|
{
|
||
|
$this->subject = $subject;
|
||
|
$this->generate_salt = $generate_salt;
|
||
|
$this->register_handle = $register_handle;
|
||
|
$this->login_handle1 = $login_handle1;
|
||
|
$this->login_handle2 = $login_handle2;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @implementation
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function register(
|
||
|
string $username,
|
||
|
string $password
|
||
|
) : bool
|
||
|
{
|
||
|
$proc = srp_client_register(
|
||
|
$this->subject,
|
||
|
$this->generate_salt,
|
||
|
$this->register_handle
|
||
|
);
|
||
|
return $proc($username, $password);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @implementation
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function passwordchange(
|
||
|
string $password
|
||
|
) : bool
|
||
|
{
|
||
|
throw (new Exception('not implemented'));
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @implementation
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function passwordreset(
|
||
|
string $username,
|
||
|
string $password,
|
||
|
string $key
|
||
|
) : bool
|
||
|
{
|
||
|
throw (new Exception('not implemented'));
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @implementation
|
||
|
* @author Christian Fraß <frass@greenscale.de>
|
||
|
*/
|
||
|
public function login(
|
||
|
string $username,
|
||
|
string $password
|
||
|
) : bool
|
||
|
{
|
||
|
$proc = srp_client_login(
|
||
|
$this->subject,
|
||
|
$this->login_handle1,
|
||
|
$this->login_handle2
|
||
|
);
|
||
|
return $proc($username, $password);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|