aboutsummaryrefslogtreecommitdiff
path: root/Psso/AuthProvider
diff options
context:
space:
mode:
authorwinter Sparkles2026-08-08 23:01:51 +0100
committerwinter Sparkles2026-08-08 23:01:51 +0100
commitb422b6ded608807c7d3bb8b965b3797ca513610b (patch)
tree7925fa972efbfff2a9bf8648334d49e3fd6b5df1 /Psso/AuthProvider
parent880a274e1ecbed42c76d3dc4a81161b3ae372726 (diff)
implement a large chunk of the auth system itself :D
Diffstat (limited to 'Psso/AuthProvider')
-rw-r--r--Psso/AuthProvider/ConfigFile.php16
-rw-r--r--Psso/AuthProvider/Dummy.php20
2 files changed, 36 insertions, 0 deletions
diff --git a/Psso/AuthProvider/ConfigFile.php b/Psso/AuthProvider/ConfigFile.php
new file mode 100644
index 0000000..0d855d0
--- /dev/null
+++ b/Psso/AuthProvider/ConfigFile.php
@@ -0,0 +1,16 @@
+<?php
+namespace Psso\AuthProvider;
+use Psso\{AuthProvider, AuthInterface};
+
+class ConfigFile extends AuthProvider implements AuthInterface\Password {
+ public function validatePassword(
+ string $username,
+ #[\SensitiveParameter] string $password
+ ): bool {
+ $hash = $this->config['users']["$username.password-hash"] ?? null;
+ if (!isset($hash)) {
+ return false;
+ }
+ return password_verify($password, $hash);
+ }
+}
diff --git a/Psso/AuthProvider/Dummy.php b/Psso/AuthProvider/Dummy.php
new file mode 100644
index 0000000..15d44ee
--- /dev/null
+++ b/Psso/AuthProvider/Dummy.php
@@ -0,0 +1,20 @@
+<?php
+namespace Psso\AuthProvider;
+use Psso\{AuthProvider, AuthInterface};
+
+class Dummy extends AuthProvider
+implements AuthInterface\Password, AuthInterface\Totp {
+ public function validatePassword(
+ string $username,
+ #[\SensitiveParameter] string $password
+ ): bool {
+ return $password == 'dummy';
+ }
+
+ public function validateTotp(
+ string $username,
+ #[\SensitiveParameter] string $otp
+ ): bool {
+ return $otp == '123456';
+ }
+}