Conversation
Al2Klimov
left a comment
There was a problem hiding this comment.
Fix your code style as told by the failing Github actions.
Al2Klimov
left a comment
There was a problem hiding this comment.
Please push without -f for now. This eases it for me to keep track of your changes.
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/DefaultPasswordPolicy.php
Outdated
Show resolved
Hide resolved
Al2Klimov
left a comment
There was a problem hiding this comment.
During setup, the wizard prompts me for a username and password "to configure your first administrative account". This should enforce the chosen password policy.
97e07ad to
39bbc53
Compare
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/CommonPasswordPolicy.php
Outdated
Show resolved
Hide resolved
library/Icinga/Application/ProvidedHook/CommonPasswordPolicy.php
Outdated
Show resolved
Hide resolved
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
test/php/library/Icinga/Application/CommonPasswordPolicyTest.php
Outdated
Show resolved
Hide resolved
That's a good idea! @JolienTrog Could you please adjust the implementation so that the validation function accepts both |
| // if($oldPassword !== null) { | ||
| $form->getElement($oldPassword); | ||
| // } |
There was a problem hiding this comment.
Sorry I forgot to delete this part.
There was a problem hiding this comment.
It is indeed necessary to do something with the element for the old password, as your introduced validator expects the old password element to be named old_password, which may not be the case. This shows that it also makes sense to introduce test cases for an actual form that implements password elements, a policy, and the validator.
doc/05-Authentication.md
Outdated
| By default, no password policy is enforced ('Any'). | ||
| Icinga Web provides a built-in policy called 'Common' with the following requirements: |
There was a problem hiding this comment.
Please annotate Any and Common as code.
| use Icinga\Authentication\PasswordPolicy; | ||
|
|
||
| /** | ||
| * This class connects with the PasswordPolicy interface to use it as hook |
There was a problem hiding this comment.
| * This class connects with the PasswordPolicy interface to use it as hook | |
| * Base class for hookable password policies |
| abstract class PasswordPolicyHook implements PasswordPolicy | ||
| { | ||
| /** | ||
| * Registers Hook as Password Policy |
There was a problem hiding this comment.
| * Registers Hook as Password Policy | |
| * Register password policy |
| */ | ||
| public static function register(): void | ||
| { | ||
| Hook::register('PasswordPolicy', static::class, static::class); |
There was a problem hiding this comment.
PasswordPolicy could be a protected const, e.g., HOOK_NAME.
| } | ||
|
|
||
| /** | ||
| * Returns all registered password policies sorted by |
There was a problem hiding this comment.
| * Returns all registered password policies sorted by | |
| * Return all registered password policies sorted by name |
|
|
||
| class AnyPasswordPolicyTest extends TestCase | ||
| { | ||
| private PasswordPolicy $instance; |
There was a problem hiding this comment.
Please rename to passwordPolicy, as everywhere else in the code.
|
|
||
| class CommonPasswordPolicyTest extends TestCase | ||
| { | ||
| protected PasswordPolicy $instance; |
There was a problem hiding this comment.
Please rename to passwordPolicy, as everywhere else in the code.
| ); | ||
| } | ||
|
|
||
| public function testMethodValidatePasswordAlwaysReturnAnEmptyArray(): void |
There was a problem hiding this comment.
| public function testMethodValidatePasswordAlwaysReturnAnEmptyArray(): void | |
| public function testValidatePasswordValid(): void |
|
|
||
| public function testValidatePasswordWithManyCharacters(): void | ||
| { | ||
| $longPassword = str_repeat('a', 1000); | ||
| $this->assertCount(3, $this->instance->validate($longPassword, 'null')); | ||
| } |
There was a problem hiding this comment.
This test is not very useful.
| public function testValidatePasswordWithManyCharacters(): void | |
| { | |
| $longPassword = str_repeat('a', 1000); | |
| $this->assertCount(3, $this->instance->validate($longPassword, 'null')); | |
| } |
doc/05-Authentication.md
Outdated
|
|
||
| class PasswordPolicy extends PasswordPolicyHook | ||
| { | ||
| use Translation; |
There was a problem hiding this comment.
You use the Translation trait only but never call $this->translate() on any of the strings.
| return $passwordPolicy; | ||
| } | ||
|
|
||
| public static function addPasswordPolicyDescription(Form $form, PasswordPolicy $passwordPolicy): void |
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Ref #4401