Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * Interface for managing user authentication.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @author    Alberto Cabello <alberto@unex.es>
13 * @copyright 2009-2026 phpMyFAQ Team
14 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
15 * @link      https://www.phpmyfaq.de
16 * @since     2009-03-01
17 */
18
19declare(strict_types=1);
20
21namespace phpMyFAQ\Auth;
22
23/**
24 * Interface Driver
25 *
26 * @package phpMyFAQ\Auth
27 */
28interface AuthDriverInterface
29{
30    /**
31     * Adds a new user account to the authentication table. The domain
32     * is only used in LDAP/AD environments. Returns true on success,
33     * otherwise false.
34     */
35    public function create(string $login, #[\SensitiveParameter] string $password, string $domain = ''): mixed;
36
37    /**
38     * Changes the password for the account specified by login.
39     * Returns true to success, otherwise false.
40     * Error messages are added to the array errors.
41     *
42     * @param string $login Login name
43     * @param string $password Password
44     */
45    public function update(string $login, #[\SensitiveParameter] string $password): bool;
46
47    /**
48     * Deletes the user account specified by login.
49     * Returns true to success, otherwise false.
50     * Error messages are added to the array errors.
51     *
52     * @param string $login Login name
53     */
54    public function delete(string $login): bool;
55
56    /**
57     * Checks the password for the given user account.
58     * Returns true if the given password for the user account specified by
59     * is correct, otherwise false.
60     * Error messages are added to the array errors.
61     * This function is only called when local authentication has failed, so
62     * we are about to create a user account.
63     *
64     * @param string $login Login name
65     * @param string $password Password
66     * @param array<string>  $optionalData Optional data
67     */
68    public function checkCredentials(
69        string $login,
70        #[\SensitiveParameter]
71        string $password,
72        ?array $optionalData = [],
73    ): bool;
74
75    /**
76     * Does nothing. A function required to be a valid auth.
77     *
78     * @param string $login Login name
79     * @param array<string>  $optionalData Optional data
80     */
81    public function isValidLogin(string $login, ?array $optionalData = []): int;
82}