From 2e1458795533181bcdb23d311dc196bc39dbc523 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 21 Feb 2019 21:04:05 +0100 Subject: [PATCH] Auth, add example authentication service and some filename cleansing. for https://github.com/opnsense/core/issues/3242 --- .../OPNsense/Auth/AuthenticationFactory.php | 4 +- .../Auth/Services/Opnsense_Auth_Test.php | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/opnsense/mvc/app/library/OPNsense/Auth/Services/Opnsense_Auth_Test.php diff --git a/src/opnsense/mvc/app/library/OPNsense/Auth/AuthenticationFactory.php b/src/opnsense/mvc/app/library/OPNsense/Auth/AuthenticationFactory.php index 1e5ed66d7..311a4f205 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Auth/AuthenticationFactory.php +++ b/src/opnsense/mvc/app/library/OPNsense/Auth/AuthenticationFactory.php @@ -146,9 +146,11 @@ class AuthenticationFactory */ public function getService($service_name) { + // cleanse service name + $srv_name = str_replace('-', '_', strtolower($service_name)); foreach (glob(__DIR__."/Services/*.php") as $filename) { $srv_found = basename($filename, '.php'); - if (strtolower($srv_found) == strtolower($service_name)) { + if (strtolower($srv_found) == $srv_name) { $reflClass = new \ReflectionClass("OPNsense\\Auth\\Services\\{$srv_found}"); if ($reflClass->implementsInterface('OPNsense\\Auth\\IService')) { return $reflClass->newInstance(); diff --git a/src/opnsense/mvc/app/library/OPNsense/Auth/Services/Opnsense_Auth_Test.php b/src/opnsense/mvc/app/library/OPNsense/Auth/Services/Opnsense_Auth_Test.php new file mode 100644 index 000000000..8a4efe0de --- /dev/null +++ b/src/opnsense/mvc/app/library/OPNsense/Auth/Services/Opnsense_Auth_Test.php @@ -0,0 +1,40 @@ +