Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add frontend user authentication and document restriction to pimcore.

| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch |
|---------|-----------------------------------|----------------------------|--------------|----------------|----------|
| **5.x** | `11.0` | `6.4` | 28.09.2023 | Feature Branch | master |
| **5.x** | `12.0.0` | `6.4` | 28.09.2023 | Feature Branch | master |
| **4.x** | `10.5 - 10.6` | `5.4` | 22.11.2021 | Unsupported | 4.x |
| **3.x** | `6.0` - `6.8` | `3.4`, `^4.4` | 21.07.2019 | Unsupported | 3.x |
| **2.5** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 18.07.2019 | Unsupported | 2.5 |
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dachcom-digital/members",
"name": "multi-concept-gmbh/members",
"type": "pimcore-bundle",
"license": [
"GPL-3.0-or-later",
Expand Down Expand Up @@ -34,8 +34,8 @@
}
},
"require": {
"pimcore/pimcore": "^11.0",
"doctrine/orm": "^2.7",
"pimcore/pimcore": "^12.0",
"doctrine/orm": "^3.0",
"symfony/form": "^6.4"
},
"require-dev": {
Expand Down
6 changes: 5 additions & 1 deletion config/packages/security_auth_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ security:
# instead the BadCredentialsException will be thrown
hide_user_not_found: false

password_hashers:
'Pimcore\Model\DataObject\MembersUser': 'members.security.pimcore_password_hasher'
'MembersBundle\Adapter\User\UserInterface': 'members.security.pimcore_password_hasher'

providers:

# [...] other providers
Expand Down Expand Up @@ -40,4 +44,4 @@ security:

- { path: ^/_locale/members/login$, role: PUBLIC_ACCESS }
- { path: ^/_locale/members/register, role: PUBLIC_ACCESS }
- { path: ^/_locale/members/resetting, role: PUBLIC_ACCESS }
- { path: ^/_locale/members/resetting, role: PUBLIC_ACCESS }
12 changes: 7 additions & 5 deletions config/security.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
security:
password_hashers:
'Pimcore\Model\DataObject\MembersUser': 'members.security.pimcore_password_hasher'
'MembersBundle\Adapter\User\UserInterface': 'members.security.pimcore_password_hasher'

services:
members.security.password_hasher_factory:
class: Pimcore\Security\Hasher\Factory\UserAwarePasswordHasherFactory
arguments:
- Pimcore\Security\Hasher\PasswordFieldHasher
- ['password']
members.security.pimcore_password_hasher:
class: MembersBundle\Security\PimcorePasswordHasher
10 changes: 5 additions & 5 deletions src/DependencyInjection/MembersExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ protected function extendPimcoreSecurityConfiguration(ContainerBuilder $containe
{
$firewallName = $container->getParameter('members.firewall_name');

$container->loadFromExtension('pimcore', [
'security' => [
'password_hasher_factories' => [
UserInterface::class => 'members.security.password_hasher_factory'
]
// Configure password hashers for Pimcore DataObjects
$container->loadFromExtension('security', [
'password_hashers' => [
'Pimcore\Model\DataObject\MembersUser' => 'members.security.pimcore_password_hasher',
UserInterface::class => 'members.security.pimcore_password_hasher'
]
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Manager/SsoIdentityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function findUserBySsoIdentity(SsoIdentityInterface $ssoIdentity): ?Us
]);

$stmt = $qb->execute();
$result = $stmt->fetchAll();
$result = $stmt->fetchAllAssociative();

if (count($result) === 1) {
return $this->userManager->findUserById((int) $result[0]['src_id']);
Expand Down
38 changes: 38 additions & 0 deletions src/Security/PimcorePasswordHasher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace MembersBundle\Security;

use Pimcore\Model\DataObject\ClassDefinition\Data\Password;
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherInterface;

class PimcorePasswordHasher implements PasswordHasherInterface
{
public function hash(string $plainPassword): string
{
// Use PHP's password_hash function which is what Pimcore uses
return password_hash($plainPassword, PASSWORD_DEFAULT);
}

public function verify(string $hashedPassword, string $plainPassword): bool
{
// Use PHP's password_verify function which is what Pimcore uses
return password_verify($plainPassword, $hashedPassword);
}

public function needsRehash(string $hashedPassword): bool
{
// Check if the password needs to be rehashed
return password_needs_rehash($hashedPassword, PASSWORD_DEFAULT);
}
}
1 change: 1 addition & 0 deletions src/Tool/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public function installDbStructure(): void
{
$db = \Pimcore\Db::get();
$db->executeQuery(file_get_contents($this->getInstallSourcesPath() . '/sql/install.sql'));
// DBAL 4.x: executeQuery returns a Result object, but we do not use the result here.
}

protected function getUserId(): int
Expand Down
Loading