2010-12-09 96 views
3

我试图使用Catalyst::Authentication::Credential::OpenID从Google身份验证用户。 验证成功后,我得到一个Catalyst::Plugin::Authentication::User::Hash对象作为我的用户。 如果用户在我的应用程序中第一次登录,我想从OpenID提供程序获取用户的详细信息并将它们存储在我的数据库中。 这是为了缓解注册过程,我希望尽可能多的来自OpenID的细节。 但至少名字,姓氏,电子邮件等。Openid - 身份验证后的用户详细信息

但我无法实现它。作为一个例子,如果我打电话,我得到异常说方法*网址,显示*没有定义。

$c->user->url 
$c->user->display 

在整理它的任何帮助是有帮助的。

+0

您寻找的具体细节是什么定义了OpenID属性交换简单注册模式?请编辑该问题以澄清。 – 2010-12-09 19:54:52

回答

2

多次阅读Catalyst手册并从Catalyst邮件列表中获得一些线索后,我才知道我们必须使用扩展。

因为我们将使用许多不同的领域,所以我使用了渐进式课程。

这里是我的应用程序中使用的示例配置,目前仅支持openID。

这将使用在 http://www.axschema.org/types/

'Plugin::Authentication' => { 
    default_realm => 'progressive', 
    realms => { 
     progressive => { 
      class => 'Progressive', 
      realms => [ 'openid' ], 
     }, 
     openid => { 
      credential => { 
       class => "OpenID", 
       store => { 
        class => "OpenID", 
       }, 
       consumer_secret => "Don't bother setting", 
       ua_class => "LWP::UserAgent", 
       # whitelist is only relevant for LWPx::ParanoidAgent 
       ua_args => { 
        whitelisted_hosts => [qw/ 127.0.0.1 localhost /], 
       }, 
       extensions => [ 
        'http://openid.net/srv/ax/1.0' => { 
         mode => 'fetch_request', 
         'type.nickname' => 'http://axschema.org/namePerson/friendly', 
         'type.email' => 'http://axschema.org/contact/email', 
         'type.fullname' => 'http://axschema.org/namePerson', 
         'type.firstname' => 'http://axschema.org/namePerson/first', 
         'type.lastname' => 'http://axschema.org/namePerson/last', 
         'type.dob' => 'http://axschema.org/birthDate', 
         'type.gender' => 'http://axschema.org/person/gender', 
         'type.country' => 'http://axschema.org/contact/country/home', 
         'type.language' => 'http://axschema.org/pref/language', 
         'type.timezone' => 'http://axschema.org/pref/timezone', 
         required => 'nickname,fullname,email,firstname,lastname,dob,gender,country', 
         if_available => 'dob,gender,language,timezone', 
        } 
       ], 
      }, 
     } 
    } 
}, 
相关问题