Zend Framework open id extensions with google - zend-framework

How to use openid extensions with google? I have something like this, I allready applied some patches which are basically the same as here: http://ak33m.com/?p=71
It does work without extensions?
$extensions = new Zend_OpenId_Extension_Sreg(array(
'nickname' => false,
'email' => true,
'fullname' => false
),
null,
'1.1'
);
if ($form->isValid($post)) {
$open_id_adapter = new App_Auth_Adapter_OpenId($post['openid_identifier'],null, null, null, $extensions);
$result = $auth->authenticate($open_id_adapter);
} else {
$open_id_adapter = new App_Auth_Adapter_OpenId(null, null, null, null, $extensions);
$result = $auth->authenticate($open_id_adapter);
}
if ($result->isValid()) {
$this->_helper->flashMessenger->addMessage(array(
'message' => 'U bent ingelogd',
'status' => 'success'
));
}

Maybe having a look at an example ZF 1.11 application that uses OpenID (including google) for authentication will clarify how to make it work (source code is also available).

Related

Where have I to define email for UrlGenerator?

In my lumen 8.0 app I want to add Resets Passwords functionality
reading Trying to reset Passwords in Lumen article but I got error :
: Route [password.reset] not defined. at /mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/laravel/lumen-framework/src/Routing/UrlGenerator.php:231)
and checking related code I see in Notifications/ResetPassword.php:
public function toMail($notifiable)
{
\Log::info( varDump($notifiable, ' -1 $notifiable::') );
\Log::info( varDump(static::$toMailCallback, ' -2 static::$toMailCallback::') );
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}
\Log::info( varDump(static::$createUrlCallback, ' -3 static::$createUrlCallback::') );
if (static::$createUrlCallback) {
$url = call_user_func(static::$createUrlCallback, $notifiable, $this->token);
} else {
$url = url(route('password.reset', [
'token' => $this->token,
'email' => $notifiable->getEmailForPasswordReset(),
], false));
}
return $this->buildMailMessage($url);
}
and checking log I see :
[2021-07-01 13:35:04] local.INFO: NULL : -2 static::$toMailCallback:: : NULL
[2021-07-01 13:35:04] local.INFO: NULL : -3 static::$createUrlCallback:: : NULL
Looks like in some config file I have to set these variables?
Could you please point where and which parameters?
Also as this article was written for lumex 5, if Notifications good decision for lumen 8?
Thanks!
Valid decision was to update config/auth.php with :
'password' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'passwords_resets',
'expire' => 60,
],
]

Codeigniter + HAuth, Authentication failed! Facebook returned an invalid user id

I am using HybridAuth Library with Codeigniter Framework, All the other Social login are working properly Except "Facebook Social Login", I am getting the error "Authentication Failed! Facebook returned an invalid user Id."
I Tried all available Answers, Like:
Hybridauth Authentication failed! Facebook returned an invalid user id
Hybridauth - PHP - Facebook returned an invalid user id
https://github.com/hybridauth/hybridauth/issues/188
https://github.com/hybridauth/hybridauth/issues/633
I am struggling from 2 days, and tried all the possible answers, still can't figure it out what is the problem, any help will be really appreciable.
Note: CURL is working properly on my server
Update
Code File
config->hybridauthlib.php
$config =
array(
'base_url' => '/hauth/endpoint/',
"providers" => array (
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "xxxxxxxx", "secret" => "xxxxxxxxxx" ),
),
);
Thirdparty->hybridauth->config.php
return
array(
"base_url" => "/hauth/endpoint/",
"Facebook" => array (
"enabled" => true,
"keys" => array ( "id" => "", "secret" => "" ),
"trustForwarded" => true,
),
I have also do changes in third_party->hybridauth->Hybrid->thirdparty->facebook->base_facebook.php as suggested by other developers
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.2',
CURLOPT_SSL_VERIFYPEER => false
);
protected $trustForwarded = true;
protected $allowSignedRequest = false;
Facebook Redirect URIs
http://localhost/myproj/index.php/hauth/endpoint?hauth.done=Facebook
I have also found same issue and resolve it. Please go to this URL:
https://github.com/aviansh26dec/hauth

First/Last record is not coming with data in cakephp+mongo

I m using the mongodb plugin
ichikaway/cakephp-mongodb
And cakephp 2.6.1
The data in post collection
link to image
And in cakephp it is showing me like
link to image
Cakephp controller side code:
$params = array(
'fields' => array('title', 'body', 'hoge'),
//'fields' => array('Post.title', ),
//'conditions' => array('title' => 'hehe'),
//'conditions' => array('hoge' => array('$gt' => '10', '$lt' => '34')),
//'order' => array('title' => 1, 'body' => 1),
'order' => array('_id' => "DESC"),
'limit' => 35,
'page' => 1,
);
$results = $this->Post->find('all', $params);
I want to pull each and every data from mongodb but this plugin is not providing me the last data.
I have checked the count that's correct.
Am I correct in assuming that this error only appeared after upgrading the PHP driver to 1.6.0? The CakePHP module uses hasNext() and getNext() in MongodbSource::read(), which will be affected by a bug (PHP-1382) introduced in 1.6.0. A fix has already been merged and should be released as 1.6.1 on 2015-02-05 (tomorrow).
For additional context, see a previous answer on the subject: https://stackoverflow.com/a/28304142/162228
In MongodbSource.php file I have made just simple change
in read function
There was a code
public function read(Model $Model, $query = array(), $recursive = null) {
........
while ($return->hasNext()) {
$mongodata = $return->getNext();
Changed it to
public function read(Model $Model, $query = array(), $recursive = null) {
........
foreach ($return as $data) {
$mongodata = $data;
And yurekaaaa,its working fine.

search good resources to implement memcached with doctrine 1.2 and zend framework

I search a good resources with examples to use a doctrine memcached and zend framework.
i search in google but not found, i need resource that Combine all this things.
using Doctrine_Cache_Memcache in zend framework.
thanks
For ZF and Doctrine integration see: beberlei's zf-doctrine at GitHub
To enable cache, in your application Bootstrap.php:
public function _initDoctrineCache()
{
$this->bootstrap('doctrine');
$manager = Doctrine_Manager::getInstance();
$cacheDriver = null;
if (extension_loaded('memcache')) {
$servers = array(
'host' => 'localhost',
'port' => 11211,
'persistent' => true
);
$cacheDriver = new Doctrine_Cache_Memcache(array(
'servers' => $servers,
'compression' => false
)
);
} else if (function_exists('apc_add')) {
$cacheDriver = new Doctrine_Cache_Apc();
}
if (null !== $cacheDriver) {
//$manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);
$manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver);
$manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE_LIFESPAN, 120); // in seconds
}
return $cacheDriver;
}
Of course, you need to have apc, memcache and memcached installed first.

Zend page caching similar to smarty?

I there a way to make zend_cache treat front end view similar to smarty? I would like to reduce load times and page caching seems the best way todo this.
Also it would need something similar to {nocache}.
Okay so I now have: Bootstrap.php
protected function _initCache() {
$this->bootstrap('locale');
$locale = $this->getResource('locale');
$front = array ( 'lifetime' => 1800,
'automatic_serialization' => false,
'caching' => true,
'cache_id_prefix' => 'ec_',
'debug_header' => true,
'default_options'
=> array ('cache_with_get_variables' => true,
'cache_with_post_variables' => false,
'cache_with_session_variables' => false,
'cache_with_cookie_variables' => false ),
);
$back = array('cache_dir' => '../data/Cache/'.$locale);
$cache = Zend_Cache::factory('Page', 'File', $front, $back);
$cache->start();
Zend_Registry::set('cache', $cache);
return $cache;
}
However, the only time my cache is hit is with code like:
$cache = Zend_Registry::get('cache');
if (!$data = $cache->load('sidebar_'.$module.'_'.$controller)) {
$data['Studio'] = Eurocreme_Studio::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => COUNT_HIGH));
$data['Movie'] = Eurocreme_Movie::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
$data['Gallery'] = Eurocreme_Gallery::load_by_type(array('type' => 'sidebar', 'from' => 0, 'to' => 5));
$data['Category'] = Eurocreme_Category::load_tree(0);
$cache->save($data, 'my_view_helper_sidebar_'.$module.'_'.$controller);
}
I was hoping to capture the entire views.
Does anyone have any working examples of how to implement it fully? The docs don't really go in-depth.
You may want to use Zend_Cache_Frontend_Output or Zend_Cache_Frontend_Page. From Zend Framework manual:
Zend_Cache_Frontend_Output is an output-capturing frontend. It utilizes output buffering in PHP to capture everything between its start() and end() methods.
Zend_Cache_Frontend_Page is like Zend_Cache_Frontend_Output but designed for a complete page.
You are probably looking for Zend_Cache_Frontend_Page. Please refer to Zend Cache docs for details.