aboutsummaryrefslogtreecommitdiff
path: root/Psso/AuthProvider/ConfigFile.php
blob: 688c193c08090fd8e9055672a807411c393f5110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
namespace Psso\AuthProvider;
use Psso\{AuthProvider, AuthInterface};

class ConfigFile extends AuthProvider
implements AuthInterface\Password, AuthInterface\UserExists {
    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);
    }

    public function userExists(string $username): bool {
        return isset($this->config['users'][$username]);
    }
}