Skip to content
Snippets Groups Projects
Commit b9103a0e authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

ldap: allow specifying the encryption used

So the user can decide between SSL/TLS.
We still default to encryption on and use the default ports since
no one required something different until now and
to not bloat the config.
parent 7206d32b
No related branches found
No related tags found
No related merge requests found
Pipeline #84299 passed with warnings
......@@ -24,6 +24,11 @@ class Configuration implements ConfigurationInterface
->scalarNode('base_dn')->end()
->scalarNode('username')->end()
->scalarNode('password')->end()
->enumNode('encryption')
->info('simple_tls uses port 636 and is sometimes referred to as "SSL", start_tls uses port 389 and is sometimes referred to as "TLS"')
->values(['start_tls', 'simple_tls'])
->defaultValue('start_tls')
->end()
->end();
$attributesBuilder = new TreeBuilder('attributes');
......
......@@ -97,8 +97,13 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
'base_dn' => $config['ldap']['base_dn'] ?? '',
'username' => $config['ldap']['username'] ?? '',
'password' => $config['ldap']['password'] ?? '',
'use_tls' => true,
];
$encryption = $config['ldap']['encryption'];
assert(in_array($encryption, ['start_tls', 'simple_tls'], true));
$this->providerConfig['use_tls'] = ($encryption === 'start_tls');
$this->providerConfig['use_ssl'] = ($encryption === 'simple_tls');
$this->providerConfig['port'] = ($encryption === 'start_tls') ? 389 : 636;
}
public function setDeploymentEnvironment(string $env)
......
......@@ -40,6 +40,7 @@ class PersonTest extends ApiTestCase
$this->api = new LDAPApi(self::createClient()->getContainer(), $eventDispatcher);
$this->api->setConfig([
'ldap' => [
'encryption' => 'simple_tls',
'attributes' => [
'email' => 'email',
'birthday' => 'dateofbirth',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment