From 39b04f0294e8eeb230eecc2ae16c82f8b812a0e0 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Tue, 12 Dec 2017 21:49:57 +0100 Subject: [PATCH] [TASK] Salted Passwords: Add a ComposedSaltInterface Add another interface, in order to allow to code against interface instead of abstractions, so composed salts that implement their own password-hashing can implement this interface. Relates: #79795 Relates: #79889 Resolves: #83294 Releases: master Change-Id: Ica97f695b5f005e7b835078e89d17f8003141b3f Reviewed-on: https://review.typo3.org/55060 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Nicole Cordes <typo3@cordes.co> Tested-by: Nicole Cordes <typo3@cordes.co> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> --- .../Classes/Salt/AbstractComposedSalt.php | 2 +- .../Classes/Salt/ComposedSaltInterface.php | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 typo3/sysext/saltedpasswords/Classes/Salt/ComposedSaltInterface.php diff --git a/typo3/sysext/saltedpasswords/Classes/Salt/AbstractComposedSalt.php b/typo3/sysext/saltedpasswords/Classes/Salt/AbstractComposedSalt.php index 3d1829f78c82..69f829f9956d 100644 --- a/typo3/sysext/saltedpasswords/Classes/Salt/AbstractComposedSalt.php +++ b/typo3/sysext/saltedpasswords/Classes/Salt/AbstractComposedSalt.php @@ -19,7 +19,7 @@ namespace TYPO3\CMS\Saltedpasswords\Salt; * Abstract class with methods needed to be extended * in a salted hashing class that composes an own salted password hash. */ -abstract class AbstractComposedSalt implements SaltInterface +abstract class AbstractComposedSalt implements ComposedSaltInterface { /** * Method applies settings (prefix, optional hash count, optional suffix) diff --git a/typo3/sysext/saltedpasswords/Classes/Salt/ComposedSaltInterface.php b/typo3/sysext/saltedpasswords/Classes/Salt/ComposedSaltInterface.php new file mode 100644 index 000000000000..467c64cbc496 --- /dev/null +++ b/typo3/sysext/saltedpasswords/Classes/Salt/ComposedSaltInterface.php @@ -0,0 +1,38 @@ +<?php +declare(strict_types=1); +namespace TYPO3\CMS\Saltedpasswords\Salt; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +/** + * Interface for implementing salts that compose the password-hash string + * themselves. + */ +interface ComposedSaltInterface extends SaltInterface +{ + /** + * Returns length of required salt. + * + * @return int Length of required salt + */ + public function getSaltLength(): int; + + /** + * Method determines if a given string is a valid salt + * + * @param string $salt String to check + * @return bool TRUE if it's valid salt, otherwise FALSE + */ + public function isValidSalt(string $salt): bool; +} -- GitLab