-
Notifications
You must be signed in to change notification settings - Fork 17
IBX-10124: Add support for Argon2 password hashes #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glye
wants to merge
28
commits into
main
Choose a base branch
from
ibx10124_argon2_password_hashes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e44627b
IBX-10124: Added basic support for Argon2I(D) password hashes
glye 5066a14
Disable setConfigResolver for CI test
glye 07b297b
Revert "Disable setConfigResolver for CI test"
glye 3ef4b6b
Set config resolver in constructor
glye 688559c
Add settings to CI
glye ef4cafc
Fix password fail logic when not upgrading hash type
glye 2993321
Remove unneeded docblock
glye 77b1de0
CS?
glye 132e4ab
Remove unneeded docblock
glye 7cddb7b
Simplify by breaking constructor BC
glye b0b111a
Use actual const in yaml config example
glye b9074bf
Review feedback
glye b375fe1
Review feedback
glye ebb1e73
Review feedback: FQCN in config hint
glye ad0d728
Compile time check for Argon2 support in PHP
glye 47b9956
Skip logger check, CS
glye 0849c9a
phpstan logger ignore
glye 7785736
Use LoggerAwareTrait
glye 37b3bf6
Rename method
glye c50ce8d
Fix logger set in ctor
glye c8dc564
Regenerated phpstan baseline
glye 69b2595
Revert "Regenerated phpstan baseline"
glye dccab56
Add logger to ctor params
glye 2a44774
Updated phpstan baseline
glye f7c2aba
!php/const in docblock example
glye 567d150
Improved config validation error message
glye 23b1d0e
Made repository aware (incomplete)
glye fca04e0
Pass repo settings directly to the hasher
glye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/bundle/Core/DependencyInjection/Configuration/Parser/Repository/PasswordHash.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Bundle\Core\DependencyInjection\Configuration\Parser\Repository; | ||
|
|
||
| use Ibexa\Bundle\Core\DependencyInjection\Configuration\RepositoryConfigParserInterface; | ||
| use Ibexa\Contracts\Core\Repository\Values\User\User; | ||
| use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|
|
||
| /** | ||
| * @internal | ||
| * | ||
| * Configuration parser for password hash configuration. | ||
| * | ||
| * Example configuration: | ||
| * ```yaml | ||
| * ibexa: | ||
| * system: | ||
| * default: # configuration per siteaccess or siteaccess group | ||
| * password_hash: | ||
| * default_type: !php/const \Ibexa\Contracts\Core\Repository\Values\User\User::PASSWORD_HASH_ARGON2I | ||
| * update_type_on_change: false | ||
| * ``` | ||
| */ | ||
| final class PasswordHash implements RepositoryConfigParserInterface | ||
| { | ||
| public function addSemanticConfig(NodeBuilder $nodeBuilder): void | ||
| { | ||
| $nodeBuilder | ||
| ->arrayNode('password_hash') | ||
| ->info('Password hash options') | ||
| ->children() | ||
| ->integerNode('default_type') | ||
| ->info('Default password hash type, see the constants in Ibexa\Contracts\Core\Repository\Values\User\User.') | ||
| ->example('!php/const:Ibexa\Contracts\Core\Repository\Values\User\User::PASSWORD_HASH_PHP_DEFAULT') | ||
| ->defaultValue(User::PASSWORD_HASH_PHP_DEFAULT) | ||
| ->validate() | ||
| ->ifTrue(static function ($value): bool { | ||
| $hashType = (int) $value; | ||
|
|
||
| if ($hashType === User::PASSWORD_HASH_ARGON2I) { | ||
| return !defined('PASSWORD_ARGON2I'); | ||
| } elseif ($hashType === User::PASSWORD_HASH_ARGON2ID) { | ||
| return !defined('PASSWORD_ARGON2ID'); | ||
| } | ||
|
|
||
| return !in_array($hashType, User::SUPPORTED_PASSWORD_HASHES, true); | ||
| }) | ||
| ->thenInvalid('Invalid password hash type "%s". If you tried to use Argon2, make sure it\'s compiled in PHP.') | ||
| ->end() | ||
| ->end() | ||
| ->booleanNode('update_type_on_change') | ||
| ->info('Whether the password hash type should be changed when the password is changed if it differs from the default type.') | ||
| ->example('false') | ||
| ->defaultFalse() | ||
| ->end() | ||
| ->end() | ||
| ->end(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/lib/Repository/User/Exception/PasswordHashTypeNotCompiled.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
| * @license For full copyright and license information view LICENSE file distributed with this source code. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Ibexa\Core\Repository\User\Exception; | ||
|
|
||
| use Ibexa\Core\Base\Exceptions\InvalidArgumentException; | ||
|
|
||
| final class PasswordHashTypeNotCompiled extends InvalidArgumentException | ||
| { | ||
| public function __construct(string $hashType) | ||
| { | ||
| parent::__construct( | ||
| 'hashType', | ||
| "Password hash algorithm $hashType is not compiled into PHP" | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.