2010-12-09 62 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', 
        } 
       ], 
      }, 
     } 
    } 
}, 
相關問題