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

标签 perl authentication openid catalyst

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

但是我做不到。例如,如果我调用,我会收到异常消息,提示方法 *url、显示 * 未定义。

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

任何有助于解决问题的帮助。

最佳答案

在多次阅读 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',
                    }
                ],
            },
        }
    }
},

关于perl - Openid - 身份验证后的用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4401821/

相关文章:

java - 什么是安全的 java applet 通信方式 -> MySQL

selenium - 登录网站时如何使用 puppeteer/selenium 重用保存的凭据/密码?

authentication - Facebook 是 OpenID 提供商吗?

asp.net-mvc - 网络场中的 MSAL AcquireTokenByAuthorizationCode

Perl双点范围运算符.. vs三点...

c - 为什么附加公共(public)后缀会反转 en_US 语言环境中的整理顺序?

regex - 搜索多个连续字符并替换为单个字符,同时排除某些字符

perl - 将字符串转换为 CRC-32 时的不同结果

node.js - Meteor 单点登录

java - 在自定义域上使用 OpenID 用户 API 时,App Engine 出现 500 服务器错误