summaryrefslogtreecommitdiff
path: root/libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php')
-rw-r--r--libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php b/libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php
new file mode 100644
index 00000000..4f889719
--- /dev/null
+++ b/libs/jsonrpc/src/JsonRPC/Validator/UserValidator.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace JsonRPC\Validator;
+
+use JsonRPC\Exception\AuthenticationFailureException;
+
+/**
+ * Class UserValidator
+ *
+ * @package JsonRPC\Validator
+ * @author Frederic Guillot
+ */
+class UserValidator
+{
+ public static function validate(array $users, $username, $password)
+ {
+ if (! empty($users) && (! isset($users[$username]) || $users[$username] !== $password)) {
+ throw new AuthenticationFailureException('Access not allowed');
+ }
+ }
+}