/** * Returns a WebServerAuth instance configured with INI config. * * @return WebServerAuth */ public static function makeConfigured() { $result = new WebServerAuth(); $result->setLdapUsers(LdapUsers::makeConfigured()); $result->setUsersManagerAPI(UsersManagerAPI::getInstance()); $result->setUsersModel(new UserModel()); $result->setUserSynchronizer(UserSynchronizer::makeConfigured()); $synchronizeUsersAfterSuccessfulLogin = Config::getShouldSynchronizeUsersAfterLogin(); $result->setSynchronizeUsersAfterSuccessfulLogin($synchronizeUsersAfterSuccessfulLogin); if (Config::getUseLdapForAuthentication()) { $fallbackAuth = LdapAuth::makeConfigured(); } else { $fallbackAuth = SynchronizedAuth::makeConfigured(); } $result->setFallbackAuth($fallbackAuth); return $result; }
public function test_SuperUsersCanLogin_IfWebServerAuthUsed_AndWebServerAuthSetupIncorreclty() { unset($_SERVER['REMOTE_USER']); $ldapAuth = WebServerAuth::makeConfigured(); $ldapAuth->setLogin(self::TEST_SUPERUSER_LOGIN); $ldapAuth->setPassword(self::TEST_SUPERUSER_PASS); $authResult = $ldapAuth->authenticate(); $this->assertEquals(AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, $authResult->getCode()); $ldapAuth = WebServerAuth::makeConfigured(); $ldapAuth->setLogin(self::TEST_SUPERUSER_LOGIN); $ldapAuth->setTokenAuth(UsersManagerAPI::getInstance()->getTokenAuth(self::TEST_SUPERUSER_LOGIN, md5(self::TEST_SUPERUSER_PASS))); $authResult = $ldapAuth->authenticate(); $this->assertEquals(AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, $authResult->getCode()); }
/** * Returns the authentication implementation to use in LoginLdap based on certain * INI configuration values. * * @return Base */ public static function factory() { if (Config::shouldUseWebServerAuthentication()) { return WebServerAuth::makeConfigured(); } else { if (Config::getUseLdapForAuthentication()) { return LdapAuth::makeConfigured(); } else { return SynchronizedAuth::makeConfigured(); } } }