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

发布于 2024-10-07 01:16:25 字数 646 浏览 0 评论 0原文

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

但我无法实现它。举个例子,如果我调用,我会得到异常,说方法 *url,display * 未定义。

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

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

I am trying to use Catalyst::Authentication::Credential::OpenID to authenticate users from Google.
Once authentication is successful, I get a Catalyst::Plugin::Authentication::User::Hash object as my user.
If users are logging in for the first time in my application, I want to get details of user from OpenID provider and store them in my DB.
This is to ease the process of registration, I want as much details from OpenID as possible.
But at least first name, last name, email etc..

But I am not able to achieve it. As an example, if I call, I get exception saying method *url,display * are not defined.

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

Any help in sorting it out is helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗化ㄋ丶相逢 2024-10-14 01:16:25

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

After reading the Catalyst manual a number of times and getting some clue from Catalyst mailing lists, I came to know that we have to use extensions.

Because we will be using a number of different realms, I used progressive class.

Here is sample configuration used in my app, currently supporting only openID.

This uses Simple Registration Schema for OpenID Attribute Exchange defined at
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',
                    }
                ],
            },
        }
    }
},
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文