1 | <?php |
||
16 | class Auth { |
||
17 | |||
18 | const PASSWORD_HASH_SALT = 'NeverChangeIt:)'; |
||
19 | |||
20 | protected $publicKeyByIp; |
||
21 | protected $passwordHash; |
||
22 | |||
23 | /** |
||
24 | * @param string $password Common password for all clients |
||
25 | * @param bool $publicKeyByIp Set public key depending on client IP |
||
26 | */ |
||
27 | public function __construct($password, $publicKeyByIp = true) { |
||
31 | |||
32 | protected final function hash($string) { |
||
35 | |||
36 | /** |
||
37 | * Get password hash like on client |
||
38 | * @param $password |
||
39 | * @return string |
||
40 | */ |
||
41 | protected final function getPasswordHash($password) { |
||
44 | |||
45 | /** |
||
46 | * Get authorization result data for client |
||
47 | * @codeCoverageIgnore |
||
48 | * @param ClientAuth|null $clientAuth |
||
49 | * @return ServerAuthStatus |
||
50 | */ |
||
51 | public final function getServerAuthStatus(ClientAuth $clientAuth = null) { |
||
57 | |||
58 | /** |
||
59 | * Check if client authorization data is valid |
||
60 | * @codeCoverageIgnore |
||
61 | * @param ClientAuth $clientAuth |
||
62 | * @return bool |
||
63 | */ |
||
64 | public final function isValidAuth(ClientAuth $clientAuth) { |
||
67 | |||
68 | /** |
||
69 | * Get client unique identification |
||
70 | * @return string |
||
71 | */ |
||
72 | protected function getClientUid() { |
||
84 | |||
85 | /** |
||
86 | * Get authorization session public key for current client |
||
87 | * @return string |
||
88 | */ |
||
89 | protected function getPublicKey() { |
||
92 | |||
93 | /** |
||
94 | * Get string signature for current password & public key |
||
95 | * @param $string |
||
96 | * @return string |
||
97 | */ |
||
98 | public final function getSignature($string) { |
||
101 | |||
102 | /** |
||
103 | * Get expected valid client authorization token |
||
104 | * @return string |
||
105 | */ |
||
106 | private final function getToken() { |
||
109 | } |
||
110 |