Skip to content
Snippets Groups Projects
Commit 62e8ffe6 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Add more implementation

parent 65fbea3a
No related branches found
No related tags found
No related merge requests found
Pipeline #63163 passed with warnings
......@@ -13,13 +13,35 @@ class Configuration implements ConfigurationInterface
{
$treeBuilder = new TreeBuilder('dbp_relay_ldap_person_provider');
$treeBuilder->getRootNode()
$cacheBuilder = new TreeBuilder('cache');
$cacheNode = $cacheBuilder->getRootNode()
->children()
->scalarNode('co_oauth2_ucardapi_client_id')->end()
->scalarNode('co_oauth2_ucardapi_client_secret')->end()
->scalarNode('co_oauth2_ucardapi_api_url')->end()
->end()
->scalarNode('person_cache_path')->end()
->scalarNode('ldap_cache_path')->end()
->end();
$treeBuilder->getRootNode()->append($cacheNode);
$ldapBuilder = new TreeBuilder('ldap');
$ldapNode = $ldapBuilder->getRootNode()
->children()
->scalarNode('host')->end()
->scalarNode('base_dn')->end()
->scalarNode('username')->end()
->scalarNode('password')->end()
->end();
$attributesBuilder = new TreeBuilder('attributes');
$attributesNode = $attributesBuilder->getRootNode()
->children()
->scalarNode('identifier')->end()
->scalarNode('given_name')->end()
->scalarNode('family_name')->end()
->scalarNode('email')->end()
->scalarNode('birthday')->end()
->end();
$ldapNode->append($attributesNode);
$treeBuilder->getRootNode()->append($ldapNode);
return $treeBuilder;
}
......
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Dbp\Relay\LdapPersonProviderBundle\DependencyInjection;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
......@@ -19,9 +20,20 @@ class DbpRelayLdapPersonProviderExtension extends ConfigurableExtension
);
$loader->load('services.yaml');
$ldapCache = $container->register('dbp_api.cache.ldap_person_provider.ldap', FilesystemAdapter::class);
$ldapCache->setArguments(['core-ldap', 360, '%kernel.cache_dir%/dbp/ldap-person-provider-ldap']);
$ldapCache->setPublic(true);
$ldapCache->addTag('cache.pool');
$personCacheDef = $container->register('dbp_api.cache.ldap_person_provider.auth_person', FilesystemAdapter::class);
$personCacheDef->setArguments(['core-auth-person', 60, '%kernel.cache_dir%/dbp/ldap-person-provider-auth-person']);
$personCacheDef->addTag('cache.pool');
// Inject the config value into the UCardService service
$definition = $container->getDefinition('Dbp\Relay\LdapPersonProviderBundle\Service\LDAPApi');
$definition->addMethodCall('setConfig', [$mergedConfig]);
$definition->addMethodCall('setLDAPCache', [$ldapCache, 360]);
$definition->addMethodCall('setPersonCache', [$personCacheDef]);
}
private function extendArrayParameter(ContainerBuilder $container, string $parameter, array $values)
......
......@@ -76,24 +76,24 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
$this->cacheTTL = 0;
$this->currentPerson = null;
$this->params = $params;
$this->providerConfig = [
'hosts' => [$this->params->get('app.ldap.host') ?? ''],
'base_dn' => $this->params->get('app.ldap.base_dn') ?? '',
'username' => $this->params->get('app.ldap.username') ?? '',
'password' => $this->params->get('app.ldap.password') ?? '',
'use_tls' => true,
];
// $this->providerConfig = [
// 'hosts' => [$this->params->get('app.ldap.host') ?? ''],
// 'base_dn' => $this->params->get('app.ldap.base_dn') ?? '',
// 'username' => $this->params->get('app.ldap.username') ?? '',
// 'password' => $this->params->get('app.ldap.password') ?? '',
// 'use_tls' => true,
// ];
$this->locator = $locator;
$this->deploymentEnv = 'production';
$this->setPersonCache(new FilesystemAdapter('app-core-auth-person', 60, (string) $this->params->get('app.cache.person-cache-path')));
$this->setLDAPCache(new FilesystemAdapter('app-core-ldap', 360, (string) $this->params->get('app.cache.ldap-cache-path')), 360);
// $this->setPersonCache(new FilesystemAdapter('app-core-auth-person', 60, (string) $this->params->get('app.cache.person-cache-path')));
// $this->setLDAPCache(new FilesystemAdapter('app-core-ldap', 360, (string) $this->params->get('app.cache.ldap-cache-path')), 360);
$this->identifierAttributeName = $this->params->get('app.ldap.attributes.identifier') ?? 'cn';
$this->givenNameAttributeName = $this->params->get('app.ldap.attributes.given_name') ?? 'givenName';
$this->familyNameAttributeName = $this->params->get('app.ldap.attributes.family_name') ?? 'sn';
$this->emailAttributeName = $this->params->get('app.ldap.attributes.email') ?? '';
$this->birthdayAttributeName = $this->params->get('app.ldap.attributes.birthday') ?? '';
// $this->identifierAttributeName = $this->params->get('app.ldap.attributes.identifier') ?? 'cn';
// $this->givenNameAttributeName = $this->params->get('app.ldap.attributes.given_name') ?? 'givenName';
// $this->familyNameAttributeName = $this->params->get('app.ldap.attributes.family_name') ?? 'sn';
// $this->emailAttributeName = $this->params->get('app.ldap.attributes.email') ?? '';
// $this->birthdayAttributeName = $this->params->get('app.ldap.attributes.birthday') ?? '';
}
public function setConfig(array $config)
......
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