Commit d4ec273e authored by Ad Schellevis's avatar Ad Schellevis

(auth) add type/description connector methods and small, for...

(auth) add type/description connector methods and small, for https://github.com/opnsense/core/issues/1085
parent 13507464
......@@ -42,6 +42,15 @@ class API implements IAuthConnector
*/
private $lastAuthProperties = array();
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'api';
}
/**
* set connector properties
* @param array $config connection properties
......
......@@ -71,7 +71,7 @@ class AuthenticationFactory
$classname = explode('.php', $pathParts[count($pathParts)-1])[0];
$reflClass = new \ReflectionClass("{$vendor}\\{$module}\\{$classname}");
if ($reflClass->implementsInterface('OPNsense\\Auth\\IAuthConnector')) {
if ($classname != 'IAuthConnector') {
if ($reflClass->hasMethod('getType')) {
$connectorType = $reflClass->getMethod('getType')->invoke(null);
$connector = array();
$connector['class'] = "{$vendor}\\{$module}\\{$classname}";
......
......@@ -141,6 +141,24 @@ class LDAP implements IAuthConnector
return $result;
}
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'ldap';
}
/**
* user friendly description of this authenticator
* @return string
*/
public function getDescription()
{
return gettext("LDAP");
}
/**
* construct a new LDAP connector
* @param null|string $baseSearchDN setup base searchDN or list of DN's separated by ;
......
......@@ -37,6 +37,15 @@ use OPNsense\Core\Config;
*/
class Local implements IAuthConnector
{
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'local';
}
/**
* set connector properties
* @param array $config connection properties
......
......@@ -53,6 +53,24 @@ class LocalTOTP extends Local
*/
private $graceperiod = 10;
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'totp';
}
/**
* user friendly description of this authenticator
* @return string
*/
public function getDescription()
{
return gettext("Local + Timebased One Time Password");
}
/**
* set connector properties
* @param array $config connection properties
......@@ -172,4 +190,5 @@ class LocalTOTP extends Local
}
return false;
}
}
......@@ -81,6 +81,24 @@ class Radius implements IAuthConnector
*/
private $lastAuthProperties = array();
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'radius';
}
/**
* user friendly description of this authenticator
* @return string
*/
public function getDescription()
{
return gettext("Radius");
}
/**
* set connector properties
* @param array $config connection properties
......
......@@ -68,6 +68,24 @@ class Voucher implements IAuthConnector
*/
private $lastAuthProperties = array();
/**
* type name in configuration
* @return string
*/
public static function getType()
{
return 'voucher';
}
/**
* user friendly description of this authenticator
* @return string
*/
public function getDescription()
{
return gettext("Voucher");
}
/**
* open database
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment