HTPasswd
HTPasswd
.htpasswd file-backed authentication adapter.
class HTPasswd extends \Hazaar\Auth\Adapter\AdapterThis adapter validates and manages user credentials stored in a traditional Apache-style passwd file. It supports multiple hash formats based on the existing user hash prefix, including:
$apr1$(APR1-MD5){SHA}(SHA1)$2y$(bcrypt/blowfish)
Authentication reads identity records from the configured passwd file, and credential create/update/delete operations write changes back to that file.
Properties
passwd
Absolute path to the passwd file used for auth record storage.
private string $passwduserHash
Stored hash template for the currently resolved user.
private string $userHash = '$apr1$'Prefix value determines which hashing algorithm branch is used.
Methods
__construct
Construct the new authentication object with the field names.
public __construct(array $config): voidParameters
| Parameter | Type | Description |
|---|---|---|
$config | array |
queryAuth
Query the authentication adapter.
public queryAuth(string $identity, array $extra, bool $): voidWe must provide a queryAuth method for the auth base class to use to look up details
Parameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | The identity |
$extra | array | Extra data to return with the authentication |
$ | bool |
getCredentialHash
Hashes a credential using the algorithm implied by the current user hash.
public getCredentialHash(?string $credential): stringParameters
| Parameter | Type | Description |
|---|---|---|
$credential | string | Plain credential to hash. Falls back to the adapter's current credential when null. |
create
Creates a new passwd file user record.
public create(string $identity, string $credential): boolParameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | identity to create |
$credential | string | plain credential to hash and store |
update
Updates an existing passwd file user credential.
public update(string $identity, string $credential): boolParameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | identity to update |
$credential | string | new plain credential to hash and store |
delete
Deletes a user record from the passwd file.
public delete(string $identity): boolParameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | identity to remove |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000