Script
Script
class Script implements \Hazaar\Warlock\Server\Interface\AuthenticatorImplements: Hazaar\Warlock\Server\Interface\Authenticator
Properties
scriptPath
private string $scriptPathType: string
Methods
__construct
Script constructor.
public __construct(string $scriptPath): voidParameters
| Parameter | Type | Description |
|---|---|---|
$scriptPath | string | the path to the authentication script that will be executed for authentication |
authenticate
Runs the authentication script and returns its result.
public authenticate(string $username, string $password, ?Client $client): boolReturns: bool
The script is included with $username, $password and $client in scope and must return a boolean, or a role name ('admin' or 'user', see Hazaar\Warlock\Server\Enum\ClientRole) to authenticate the client with that role. true gives the client the user role (real-time signalling only) unless the script set $client->role itself, because scripts are how end users such as browsers are authenticated. Return 'admin' for trusted clients that need the server-control and KV commands.
It is also run when no credentials were sent (both strings empty) so it can authenticate a client from its handshake headers alone, e.g. $client->getHeader('cookie') for a browser's session cookie. A script that authenticates that way can set $client->username to the identity it found. It can also restrict the client's events with $client->allowSubscribe and $client->allowTrigger.
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string | |
$password | string | |
$client | Hazaar\Warlock\Server\Client |
exists
public exists(string $username): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string |
addUser
Add a new user with the specified password.
public addUser(string $username, string $password): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string | the username of the new user |
$password | string | the password for the new user |
removeUser
Remove an existing user.
public removeUser(string $username): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string | the username of the user to remove |
listUsers
List all existing users.
public listUsers(): arrayReturns: array
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:31 +0000