-
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
5619382
IBX-10124: Added basic support for Argon2I(D) password hashes
glye 835bbe7
Disable setConfigResolver for CI test
glye e99645c
Revert "Disable setConfigResolver for CI test"
glye 2e03b94
Set config resolver in constructor
glye b8c684d
Add settings to CI
glye b7dd4c0
Fix password fail logic when not upgrading hash type
glye fe7651b
Remove unneeded docblock
glye 0b19e3f
CS?
glye 5e1c8b1
Remove unneeded docblock
glye d86ba0a
Simplify by breaking constructor BC
glye 7f11814
Use actual const in yaml config example
glye dfbb652
Review feedback
glye 0d4d4ac
Review feedback
glye eaa90ce
Review feedback: FQCN in config hint
glye 77b393e
Compile time check for Argon2 support in PHP
glye e27b389
Skip logger check, CS
glye 4976267
phpstan logger ignore
glye 082fd2a
Use LoggerAwareTrait
glye a27f017
Rename method
glye f139500
Fix logger set in ctor
glye 915c86b
Regenerated phpstan baseline
glye 75c19e9
Revert "Regenerated phpstan baseline"
glye 07a2095
Add logger to ctor params
glye 56d9f36
Updated phpstan baseline
glye 7c32aed
!php/const in docblock example
glye ac3ca36
Improved config validation error message
glye d30dd4e
Made repository aware (incomplete)
glye a258078
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.