Updated dependencies and build chain
This commit is contained in:
1 parent
6d59a931c8
commit
ce9686079f
16 files changed
+78
-74
No files matched your search
@@ -7,23 +7,5 @@ on:
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
ecs:
|
||||
name: build-tools
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zlib
|
||||
coverage: none
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install the dependencies
|
||||
run: |
|
||||
composer install --no-interaction --no-progress
|
||||
|
||||
- name: Run all build-tools to validate code
|
||||
run: composer run build-tools
|
||||
ci:
|
||||
uses: 'terminal42/contao-build-tools/.github/workflows/build-tools.yml@main'
|
||||
+19
-5
@@ -27,13 +27,19 @@
|
||||
"forum": "https://community.contao.org"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"php": "^8.2",
|
||||
"contao/core-bundle": "^4.13 || ^5.0",
|
||||
"doctrine/dbal": "^3.3",
|
||||
"paragonie/hidden-string": "^1.0",
|
||||
"symfony/config": "^5.0 || ^6.0",
|
||||
"symfony/dependency-injection": "^5.0 || ^6.0",
|
||||
"symfony/http-client": "^5.0 || ^6.0",
|
||||
"symfony/http-kernel": "^5.0 || ^6.0"
|
||||
"symfony/config": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/dependency-injection": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/http-client-contracts": "^3",
|
||||
"symfony/http-foundation": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/http-kernel": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/password-hasher": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/security-core": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/string": "^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/translation-contracts": "^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"contao/manager-plugin": "^2.7",
|
||||
@@ -46,5 +52,13 @@
|
||||
},
|
||||
"extra": {
|
||||
"contao-manager-plugin": "Terminal42\\PasswordValidationBundle\\ContaoManager\\Plugin"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"contao-components/installer": false,
|
||||
"php-http/discovery": false,
|
||||
"contao/manager-plugin": false,
|
||||
"terminal42/contao-build-tools": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ services:
|
||||
- '@terminal42_password_validation.validator_configuration'
|
||||
- '@request_stack'
|
||||
- '@contao.routing.scope_matcher'
|
||||
- '@security.helper'
|
||||
- '@security.authorization_checker'
|
||||
|
||||
Terminal42\PasswordValidationBundle\EventListener\PasswordHistoryListener:
|
||||
arguments:
|
||||
@@ -25,7 +25,7 @@ services:
|
||||
Terminal42\PasswordValidationBundle\EventListener\RedirectToPasswordChangePageListener:
|
||||
arguments:
|
||||
- '@contao.framework'
|
||||
- '@security.helper'
|
||||
- '@security.token_storage'
|
||||
- '@contao.routing.scope_matcher'
|
||||
tags:
|
||||
- kernel.event_listener
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
- '#no value type specified in iterable type array#'
|
||||
@@ -17,11 +17,11 @@ use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
/**
|
||||
* This class adds a warning if some root pages lack of a configured password-change page.
|
||||
*/
|
||||
final class NoPwChangePageWarning
|
||||
final readonly class NoPwChangePageWarning
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
* This listener forces a password change for passwords being too old.
|
||||
*/
|
||||
#[AsHook('postLogin')]
|
||||
final class PasswordChangeListener
|
||||
final readonly class PasswordChangeListener
|
||||
{
|
||||
public function __construct(private readonly ValidationConfiguration $configuration)
|
||||
public function __construct(private ValidationConfiguration $configuration)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
/**
|
||||
* This listener adds the new password to the password history.
|
||||
*/
|
||||
final class PasswordHistoryListener
|
||||
final readonly class PasswordHistoryListener
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly PasswordHasherFactoryInterface $encoderFactory,
|
||||
private readonly Connection $connection,
|
||||
private ValidationConfiguration $configuration,
|
||||
private PasswordHasherFactoryInterface $encoderFactory,
|
||||
private Connection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use Contao\ModuleRegistration;
|
||||
use Contao\Widget;
|
||||
use ParagonIE\HiddenString\HiddenString;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Terminal42\PasswordValidationBundle\Exception\PasswordValidatorException;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
@@ -24,14 +24,14 @@ use Terminal42\PasswordValidationBundle\Validation\ValidatorManager;
|
||||
* This listener validates the password input by providing a regexp.
|
||||
*/
|
||||
#[AsHook('addCustomRegexp')]
|
||||
final class PasswordRegexpListener
|
||||
final readonly class PasswordRegexpListener
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidatorManager $validatorManager,
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly RequestStack $requestStack,
|
||||
private readonly ScopeMatcher $scopeMatcher,
|
||||
private readonly Security $security,
|
||||
private ValidatorManager $validatorManager,
|
||||
private ValidationConfiguration $configuration,
|
||||
private RequestStack $requestStack,
|
||||
private ScopeMatcher $scopeMatcher,
|
||||
private AuthorizationCheckerInterface $authorizationChecker,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ final class PasswordRegexpListener
|
||||
} elseif ($dc instanceof ModuleRegistration) {
|
||||
$userId = null;
|
||||
$userEntity = FrontendUser::class;
|
||||
} elseif ($request && $this->scopeMatcher->isFrontendRequest($request) && $this->security->isGranted('ROLE_MEMBER')) {
|
||||
} elseif ($request && $this->scopeMatcher->isFrontendRequest($request) && $this->authorizationChecker->isGranted('ROLE_MEMBER')) {
|
||||
$userId = (int) FrontendUser::getInstance()->id;
|
||||
$userEntity = FrontendUser::class;
|
||||
} elseif (
|
||||
|
||||
@@ -11,14 +11,14 @@ use Contao\CoreBundle\Routing\ScopeMatcher;
|
||||
use Contao\FrontendUser;
|
||||
use Contao\PageModel;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
final class RedirectToPasswordChangePageListener
|
||||
final readonly class RedirectToPasswordChangePageListener
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ContaoFramework $framework,
|
||||
private readonly Security $security,
|
||||
private readonly ScopeMatcher $scopeMatcher,
|
||||
private ContaoFramework $framework,
|
||||
private TokenStorageInterface $tokenStorage,
|
||||
private ScopeMatcher $scopeMatcher,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ final class RedirectToPasswordChangePageListener
|
||||
}
|
||||
|
||||
$request = $event->getRequest();
|
||||
$user = $this->security->getUser();
|
||||
$user = $this->tokenStorage->getToken()?->getUser();
|
||||
$page = $request->attributes->get('pageModel');
|
||||
|
||||
if (!$page instanceof PageModel || !$user instanceof FrontendUser || !$user->pwChange) {
|
||||
@@ -38,7 +38,7 @@ final class RedirectToPasswordChangePageListener
|
||||
|
||||
/** @var PageModel $adapter */
|
||||
$adapter = $this->framework->getAdapter(PageModel::class);
|
||||
$rootPage = $adapter->findByPk($page->rootId);
|
||||
$rootPage = $adapter->findById($page->rootId);
|
||||
|
||||
// Search for password-change page
|
||||
$pwChangePage = $adapter->findPublishedById($rootPage->pwChangePage ?? 0);
|
||||
|
||||
@@ -19,12 +19,12 @@ use ParagonIE\HiddenString\HiddenString;
|
||||
/**
|
||||
* This class holds useful information (e.g. the password to validate) for the validator.
|
||||
*/
|
||||
final class ValidationContext
|
||||
final readonly class ValidationContext
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $userEntity,
|
||||
private readonly int|null $userId,
|
||||
private readonly HiddenString $password,
|
||||
private string $userEntity,
|
||||
private int|null $userId,
|
||||
private HiddenString $password,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ use Terminal42\PasswordValidationBundle\Validation\PasswordValidatorInterface;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
|
||||
final class HaveIBeenPwned implements PasswordValidatorInterface
|
||||
final readonly class HaveIBeenPwned implements PasswordValidatorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly HttpClientInterface $client,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private HttpClientInterface $client,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use Terminal42\PasswordValidationBundle\Validation\PasswordValidatorInterface;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
|
||||
final class MaximumLength implements PasswordValidatorInterface
|
||||
final readonly class MaximumLength implements PasswordValidatorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use Terminal42\PasswordValidationBundle\Validation\PasswordValidatorInterface;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
|
||||
final class MinimumLength implements PasswordValidatorInterface
|
||||
final readonly class MinimumLength implements PasswordValidatorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@ use Terminal42\PasswordValidationBundle\Validation\PasswordValidatorInterface;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
|
||||
final class PasswordHistory implements PasswordValidatorInterface
|
||||
final readonly class PasswordHistory implements PasswordValidatorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly PasswordHasherFactoryInterface $encoderFactory,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private PasswordHasherFactoryInterface $encoderFactory,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ use Terminal42\PasswordValidationBundle\Validation\PasswordValidatorInterface;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationConfiguration;
|
||||
use Terminal42\PasswordValidationBundle\Validation\ValidationContext;
|
||||
|
||||
final class RequiredCharacters implements PasswordValidatorInterface
|
||||
use function Symfony\Component\String\s;
|
||||
|
||||
final readonly class RequiredCharacters implements PasswordValidatorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ValidationConfiguration $configuration,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private ValidationConfiguration $configuration,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -91,12 +93,12 @@ final class RequiredCharacters implements PasswordValidatorInterface
|
||||
{
|
||||
switch ($category) {
|
||||
case 'lowercase':
|
||||
$uppercase = mb_strtoupper($string);
|
||||
$uppercase = s($string)->upper()->toString();
|
||||
|
||||
return \strlen($uppercase) - similar_text($string, $uppercase);
|
||||
|
||||
case 'uppercase':
|
||||
$lowercase = mb_strtolower($string);
|
||||
$lowercase = s($string)->lower()->toString();
|
||||
|
||||
return \strlen($lowercase) - similar_text($string, $lowercase);
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ final class ValidatorManager
|
||||
*/
|
||||
private array $validators;
|
||||
|
||||
/**
|
||||
* @param iterable<PasswordValidatorInterface> $validators
|
||||
*/
|
||||
public function __construct(iterable $validators)
|
||||
{
|
||||
$this->validators = $validators instanceof \Traversable ? iterator_to_array($validators) : $validators;
|
||||
|
||||
Reference in new issue
Block a user