Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Add LDAP encryption and version fields
*/
// phpcs:disable Squiz.Classes.ValidClassName
// phpcs:disable Generic.Files.LineLength
final class Version20251107100000_add_ldap_encryption_and_version extends AbstractMigration
{
public function getDescription(): string
{
return 'Add LDAP encryption and version fields to connector table';
}

public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE connector ADD ldap_encryption VARCHAR(255) DEFAULT \'none\', ADD ldap_version INT DEFAULT 3');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE connector DROP ldap_encryption, DROP ldap_version');
}
}
30 changes: 30 additions & 0 deletions app/src/Entity/LdapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class LdapConnector extends Connector
#[ORM\Column(length: 255, nullable: true)]
private ?string $ldapSharedWithField = null;

#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $ldapEncryption = 'none';

#[ORM\Column(type: 'integer', nullable: true)]
private ?int $ldapVersion = 3;


public function getLdapHost(): ?string
{
Expand Down Expand Up @@ -222,4 +228,28 @@ public function setLdapSharedWithField(?string $ldapSharedWithField): static

return $this;
}

public function getLdapEncryption(): ?string
{
return $this->ldapEncryption;
}

public function setLdapEncryption(?string $ldapEncryption): static
{
$this->ldapEncryption = $ldapEncryption;

return $this;
}

public function getLdapVersion(): ?int
{
return $this->ldapVersion;
}

public function setLdapVersion(?int $ldapVersion): static
{
$this->ldapVersion = $ldapVersion;

return $this;
}
}
15 changes: 15 additions & 0 deletions app/src/Form/LdapConnectorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use App\Entity\Groups;
use App\Repository\GroupsRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand All @@ -28,6 +30,19 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'Entities.LdapConnector.fields.ldapPort',
'attr' => ['pattern' => '[0-9]+']
])
->add('ldapEncryption', ChoiceType::class, [
'required' => true,
'label' => 'Entities.LdapConnector.fields.ldapEncryption',
'choices' => [
'None' => 'none',
'SSL' => 'ssl',
'TLS' => 'tls',
],
])
->add('ldapVersion', IntegerType::class, [
'required' => true,
'label' => 'Entities.LdapConnector.fields.ldapVersion',
])
->add('LdapBaseDN', null, [
'required' => true,
'label' => 'Entities.LdapConnector.fields.LdapBaseDN',
Expand Down
4 changes: 4 additions & 0 deletions app/src/Service/LdapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function bind(LdapConnector $connector): Ldap
$ldap = Ldap::create('ext_ldap', [
'host' => $connector->getLdapHost(),
'port' => $connector->getLdapPort(),
'encryption' => $connector->getLdapEncryption(),
'version' => $connector->getLdapVersion(),
]);

if ($connector->isAllowAnonymousBind()) {
Expand Down Expand Up @@ -67,6 +69,8 @@ public function bindUser(User $user, string $password): bool
$ldap = Ldap::create('ext_ldap', [
'host' => $originConnector->getLdapHost(),
'port' => $originConnector->getLdapPort(),
'encryption' => $originConnector->getLdapEncryption(),
'version' => $originConnector->getLdapVersion(),
]);

try {
Expand Down
2 changes: 2 additions & 0 deletions app/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ Entities:
connectionInformation: "Connection information"
ldapHost: "Host"
ldapPort: "Port (default 389)"
ldapEncryption: "Encryption"
ldapVersion: "LDAP version"
allowAnonymousBind: "Anonymous connection"
LdapBaseDN: "Base DN"
ldapBindDn: "Bind DN"
Expand Down
2 changes: 2 additions & 0 deletions app/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ Entities:
connectionInformation: "Informations de connexion"
ldapHost: "Hôte"
ldapPort: "Port (défaut 389)"
ldapEncryption: "Chiffrement"
ldapVersion: "Version LDAP"
allowAnonymousBind: "Connexion anonyme"
LdapBaseDN: "Base DN"
ldapBindDn: "Bind DN"
Expand Down