Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI

on:
# Run on all pushes to master and on all pull requests.
push:
branches:
master
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
test:
uses: "zetacomponents/.github/.github/workflows/ci.yml@master"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vendor
run-tests-tmp
extract
extract
.phpunit.result.cache
composer.lock

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"zetacomponents/base": "~1.8"
},
"require-dev": {
"zetacomponents/unit-test": "*"
"zetacomponents/unit-test": "*",
"phpunit/phpunit": "~9.0"
}
}
9 changes: 2 additions & 7 deletions docs/tutorial/tutorial_autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
}

/**
* Autoload ezc classes
*
* @param string $className
* Autoload ezc classes
*/
function __autoload( $className )
{
ezcBase::autoload( $className );
}
spl_autoload_register('ezcBase::autoload');
?>
2 changes: 1 addition & 1 deletion docs/tutorial/tutorial_token1.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$token = "";
for( $i = 1; $i <= 6 ; $i++ )
{
$token .= $pattern{rand( 0, 36 )};
$token .= $pattern[rand( 0, 36 )];
}
$encryptedToken = sha1( $token );

Expand Down
25 changes: 12 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Zeta Components Authentication">
<directory suffix="_test.php">./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Zeta Components Authentication">
<directory suffix="_test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
17 changes: 9 additions & 8 deletions src/authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -84,21 +84,21 @@ class ezcAuthentication
{
/**
* The filter queue of the authentication process.
*
*
* @var array(ezcAuthenticationFilter)
*/
protected $filters = array();

/**
* Options for the Authentication object.
*
*
* @var ezcAuthenticationOptions
*/
protected $options;

/**
* The properties of this class.
*
*
* @var array(string=>mixed)
*/
private $properties = array();
Expand All @@ -109,7 +109,7 @@ class ezcAuthentication
* @param ezcAuthenticationCredentials $credentials Authentication credentials
* @param ezcAuthenticationOptions $options Options for this class
*/
public function __construct( ezcAuthenticationCredentials $credentials, ezcAuthenticationOptions $options = null )
public function __construct( ezcAuthenticationCredentials $credentials, ?ezcAuthenticationOptions $options = null )
{
$this->credentials = $credentials;
$this->status = new ezcAuthenticationStatus();
Expand Down Expand Up @@ -263,7 +263,8 @@ public function run()
// status of the Authentication object
foreach ( $statuses as $status )
{
list( $key, $value ) = each( $status );
$key = key( $status );
$value = current( $status );
$this->status->append( $key, $value );
}
}
Expand Down Expand Up @@ -328,7 +329,7 @@ public function addFilter( ezcAuthenticationFilter $filter, $stop = false )
* array( 'ezcAuthenticationDatabaseFilter' => ezcAuthenticationDatabaseFilter::STATUS_PASSWORD_INCORRECT )
* );
* </code>
*
*
* @return array(string=>mixed)
*/
public function getStatus()
Expand Down
12 changes: 6 additions & 6 deletions src/filters/group/group_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -170,14 +170,14 @@ class ezcAuthenticationGroupFilter extends ezcAuthenticationFilter

/**
* Authentication filters.
*
*
* @var array(ezcAuthenticationFilter)
*/
protected $filters = array();

/**
* The properties of this class.
*
*
* @var array(string=>mixed)
*/
private $properties = array();
Expand Down Expand Up @@ -215,7 +215,7 @@ class ezcAuthenticationGroupFilter extends ezcAuthenticationFilter
* @param array(ezcAuthenticationFilter|mixed) $filters Authentication filters
* @param ezcAuthenticationGroupOptions $options Options for this class
*/
public function __construct( array $filters, ezcAuthenticationGroupOptions $options = null )
public function __construct( array $filters, ?ezcAuthenticationGroupOptions $options = null )
{
$this->options = ( $options === null ) ? new ezcAuthenticationGroupOptions() : $options;

Expand Down Expand Up @@ -399,7 +399,7 @@ public function run( $credentials )
* with $filter if the multipleCredentials
* option is enabled
*/
public function addFilter( ezcAuthenticationFilter $filter, ezcAuthenticationCredentials $credentials = null )
public function addFilter( ezcAuthenticationFilter $filter, ?ezcAuthenticationCredentials $credentials = null )
{
if ( $this->options->multipleCredentials === true )
{
Expand Down
8 changes: 4 additions & 4 deletions src/filters/htpasswd/htpasswd_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -108,7 +108,7 @@ class ezcAuthenticationHtpasswdFilter extends ezcAuthenticationFilter
* @param string $file The path and file name of the htpasswd file to use
* @param ezcAuthenticationHtpasswdOptions $options Options for this class
*/
public function __construct( $file, ezcAuthenticationHtpasswdOptions $options = null )
public function __construct( $file, ?ezcAuthenticationHtpasswdOptions $options = null )
{
$this->file = $file;
$this->options = ( $options === null ) ? new ezcAuthenticationHtpasswdOptions() : $options;
Expand Down Expand Up @@ -232,7 +232,7 @@ public function run( $credentials )
}
else
{
$password = ( $this->options->plain ) ? crypt( $credentials->password, $hashFromFile ) :
$password = ( $this->options->plain ) ? crypt( $credentials->password ? $credentials->password : '', $hashFromFile ) :
$credentials->password;
}
if ( $password === $hashFromFile )
Expand Down
6 changes: 3 additions & 3 deletions src/filters/ldap/ldap_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -153,7 +153,7 @@ class ezcAuthenticationLdapFilter extends ezcAuthenticationFilter implements ezc
* @param ezcAuthenticationLdapInfo $ldap How to connect to LDAP
* @param ezcAuthenticationLdapOptions $options Options for this class
*/
public function __construct( ezcAuthenticationLdapInfo $ldap, ezcAuthenticationLdapOptions $options = null )
public function __construct( ezcAuthenticationLdapInfo $ldap, ?ezcAuthenticationLdapOptions $options = null )
{
if ( !ezcBaseFeatures::hasExtensionSupport( 'ldap' ) )
{
Expand Down
6 changes: 3 additions & 3 deletions src/filters/openid/openid_file_store.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -67,7 +67,7 @@ class ezcAuthenticationOpenidFileStore extends ezcAuthenticationOpenidStore
* @param string $path The path where to save the nonces
* @param ezcAuthenticationOpenidFileStoreOptions $options Options for this class
*/
public function __construct( $path, ezcAuthenticationOpenidFileStoreOptions $options = null )
public function __construct( $path, ?ezcAuthenticationOpenidFileStoreOptions $options = null )
{
$this->path = $path;
$this->options = ( $options === null ) ? new ezcAuthenticationOpenidFileStoreOptions() : $options;
Expand Down
8 changes: 4 additions & 4 deletions src/filters/openid/openid_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -368,7 +368,7 @@ class ezcAuthenticationOpenidFilter extends ezcAuthenticationFilter implements e
*
* @param ezcAuthenticationOpenidOptions $options Options for this class
*/
public function __construct( ezcAuthenticationOpenidOptions $options = null )
public function __construct( ?ezcAuthenticationOpenidOptions $options = null )
{
$this->options = ( $options === null ) ? new ezcAuthenticationOpenidOptions() : $options;
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ protected function checkSignatureSmart( ezcAuthenticationOpenidAssociation $asso
{
$serialized .= "{$key}:{$value}\n";
}

$key = base64_decode( $association->secret );
if ( strlen( $key ) > 64 )
{
Expand Down
8 changes: 4 additions & 4 deletions src/filters/token/token_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -108,7 +108,7 @@ class ezcAuthenticationTokenFilter extends ezcAuthenticationFilter
* @param callback $function The encryption function to use when comparing tokens
* @param ezcAuthenticationTokenOptions $options Options for this class
*/
public function __construct( $token, $function, ezcAuthenticationTokenOptions $options = null )
public function __construct( $token, $function, ?ezcAuthenticationTokenOptions $options = null )
{
$this->token = $token;
$this->function = $function;
Expand Down Expand Up @@ -207,7 +207,7 @@ public function __isset( $name )
*/
public function run( $credentials )
{
$password = call_user_func( $this->function, $credentials->id );
$password = call_user_func( $this->function, $credentials->id ? $credentials->id : '' );
if ( $this->token === $password )
{
return self::STATUS_OK;
Expand Down
6 changes: 3 additions & 3 deletions src/filters/typekey/typekey_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -255,7 +255,7 @@ class ezcAuthenticationTypekeyFilter extends ezcAuthenticationFilter implements
* if neither of the PHP gmp and bcmath extensions are installed
* @param ezcAuthenticationTypekeyOptions $options Options for this class
*/
public function __construct( ezcAuthenticationTypekeyOptions $options = null )
public function __construct( ?ezcAuthenticationTypekeyOptions $options = null )
{
$this->options = ( $options === null ) ? new ezcAuthenticationTypekeyOptions() : $options;
$this->lib = ezcAuthenticationMath::createBignumLibrary();
Expand Down
8 changes: 4 additions & 4 deletions src/math/math.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -102,7 +102,7 @@ public static function createBignumLibrary( $lib = null )
/**
* Calculates an MD5 hash similar to the Unix command "htpasswd -m".
*
* This is different from the hash returned by the PHP md5() function.
* This is different from the hash returned by the PHP md5() function.
*
* @param string $plain Plain text to encrypt
* @param string $salt Salt to apply to encryption
Expand All @@ -126,7 +126,7 @@ public static function apr1( $plain, $salt )
}
for ( $i = strlen( $plain ); $i; $i >>= 1 )
{
$text .= ( $i & 1 ) ? chr( 0 ) : $plain{0};
$text .= ( $i & 1 ) ? chr( 0 ) : $plain[0];
}
$bin = pack( 'H32', md5( $text ) );
for ( $i = 0; $i ^ 1000; ++$i )
Expand Down
2 changes: 1 addition & 1 deletion src/session/authentication_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ezcAuthenticationSession
*
* @param ezcAuthenticationSessionOptions $options Options for this class
*/
public function __construct( ezcAuthenticationSessionOptions $options = null )
public function __construct( ?ezcAuthenticationSessionOptions $options = null )
{
$this->options = ( $options === null ) ? new ezcAuthenticationSessionOptions() : $options;
}
Expand Down
Loading