Class HttpAuth
PHP Library to make use of HTTP Authentication
- CJPGDK\PhpHttpAuth\HttpAuth uses CJPGDK\PhpHttpAuth\Hash\Bcrypt, CJPGDK\PhpHttpAuth\Hash\Sha, CJPGDK\PhpHttpAuth\Hash\Apr1Md5
Package: CJPGDK\PhpHttpAuth
Copyright: (c) 2017, Christian M. Jensen cmj@cjpg.dk
License: The MIT License
Author: Christian M. Jensen cmj@cjpg.dk
Version: 1.0.0
Located at src/CJPGDK/PhpHttpAuth/HttpAuth.php
public
|
|
public
|
|
public
|
|
public
array
|
|
public static
|
#
getInstance( boolean $new = false,
Get an instance of this class, and cache the object for future use. |
public
|
#
setUsersFile( string $htpasswd )
set the full/relative path to htpasswd file, to use for authenticating users. |
public
|
|
public
|
|
public
|
|
public
|
|
protected
string
|
|
protected
string
|
#
getUsername( string $username )
Get the username of username if it exists in the user table. if no user is found returns an empty string |
public
string
|
|
public
boolean
|
#
hasValidCredentials( string $realm = 'Restricted area' )
Check if the visitor has send us some credentials |
public
boolean
|
|
public
|
#
requestReAuthBasic( string $realm = 'Restricted area', string $message = 'Restricted area' )
request the visitor to authenticate again, ignoring the current user and password set |
public
boolean
|
#
matchPasswd( string $plain, string $hash, boolean $allowPlain = false )
check the password matches APR1-MD5, SHA1, Bcrypt or if allowed plain text |
public
boolean
|
#
validateAuthDigestResponse( string $realm = 'Restricted area', array|null $data = null )
Validate an wuthentication request using auth digest |
public
boolean|array
|
|
public
|
#
requestReAuthDigest( string $realm = 'Restricted area', string $message = 'Restricted area' )
Send headers requesting http auth digest, if the user hits cancel the text from $message will be displayed and the script dies |
public
|
#
authDigest( string $realm = 'Restricted area', string $message = 'Restricted area' )
Send headers requesting http auth digest, if the user hits cancel the tekst from $message will be displayed and the script dies |
public
mixed
|
#
getServerVariableValue( string $name, mixed $default = null )
Get the value of _SERVER variable by name |
public
|
|
public
|
#
sendHeader( string $string, boolean $replace = true, integer $http_response_code = null )
Send a raw HTTP header |
createUserBcrypt(),
getBcryptHash(),
getBcryptHtpasswdRow(),
matchBcryptHash()
|
createUserSha(),
getShaHash(),
getShaHtpasswdRow(),
matchShaHash()
|
createUserApr1Md5(),
getApr1Md5Hash(),
getApr1Md5HtpasswdRow(),
matchApr1Md5Hash()
|
public
boolean
|
$allowPlainPassword
Allow login by plain text passwords |
#
false
|