Openid - 身份验证后的用户详细信息

时间:2010-12-09 18:36:46

标签: perl authentication openid catalyst

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

但我无法实现它。作为一个例子,如果我打电话,我得到例外方法* url,display *未定义。

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

任何帮助整理出来都很有帮助。

1 个答案:

答案 0 :(得分:2)

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

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

以下是我的应用中使用的示例配置,目前仅支持openID。

这使用了定义的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',
                    }
                ],
            },
        }
    }
},
相关问题