This topic contains 2 replies, has 2 voices, and was last updated by Stepan Yudin 7 years, 10 months ago.
- Topic
I really miss LDAP integration in Community Edition so here is my way to implement this.
Maybe someone will find it useful)1) Create custom authenticator (see Symfony Cookbook for more info) and declare it as a service (if your want it as a service)
123456789101112131415161718192021222324252627282930313233343536373839404142<?php//Namespace definition and use statementsclass LDAPAuthenticator implements SimpleFormAuthenticatorInterface{public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey){// Lets authorize thru LDAP/AD first$authSuccess = false;$username = token->getUsername();$password = $token->getCredentials();// Here is your code to check user credentials via LDAP/AD or any other mechanism// If access denied - throw new AuthenticationException("Sloni idut na sever");// If allowed - $authSuccess = true;$authSuccess = true;// If user authenticatedif ($authSuccess) {return new UsernamePasswordOrganizationToken(// Here you must provide user params - get 'em from app users table or another source);}throw new AuthenticationException('Invalid username or password');}public function supportsToken(TokenInterface $token, $providerKey){return $token instanceof UsernamePasswordOrganizationToken&& $token->getProviderKey() === $providerKey;}public function createToken(Request $request, $username, $password, $providerKey){return new UsernamePasswordOrganizationToken(// Here you must provide user params - get 'em from app users table or another source);}}2) Override standard out of the box security authenticator via our custom authenticator in security.yml:
1234567891011121314151617181920...main:pattern: ^/provider: chain_provider#comment next line to disable standard implementation#organization-form-login:#and switch to simple_formsimple_form:#use our custom LDAPAuthenticator (declared as a service)authenticator: app.security.ldap_authenticatorcsrf_provider: form.csrf_providercheck_path: oro_user_security_checklogin_path: oro_user_security_login...3) Don’t forget to write your custom auth algorithm in my example authenticator class.
4) Sorry for dirty code, its just an example to show how make it work
Docker environment for Symfony2/OroCRM/OroBAP development on Windows platform
https://github.com/stepansib/sf-oro-docker
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.