“苏”相当于 Web 应用程序身份验证、设计问题

发布于 2024-10-19 07:24:10 字数 442 浏览 6 评论 0原文

我开发并维护一个用 Perl/Catalyst 编写的客户门户。我们使用 Catalyst 身份验证插件(带有 LDAP 存储后端,加上一些 Deny_unless 规则,以确保正确的人员拥有正确的组成员身份)。

通常,在管理客户的权限时,我们需要在交付之前测试用户的设置。目前,我们唯一的办法是重置用户密码并自己登录,但这不太理想,特别是如果用户已经设置了自己的密码等。

我的问题是:对于 Catalyst,有没有人遇到过一种方法模拟用户帐户,以便在获得正确的超级管理员权限的情况下,可以在测试设置时暂时模拟另一个帐户,然后在完成后退出?

如果不是在 Catalyst 中,那么人们如何在其他框架或他们自己的自定义解决方案中解决这个问题?诚然,这会给 Web 应用程序带来潜在的严重攻击向量,但如果强制实施,人们如何为此进行设计呢?也许是一些严肃的cookie-session-fu?或者可能是实际ID/有效ID 系统?

I develop and maintain a customer portal, written in Perl/Catalyst. We make use of the Catalyst authentication plugins (w/ an LDAP storage backend, coupled with a few deny_unless rules to ensure the right people have the right group membership).

It's often that in managing a customer's permissions, we have the need to test out a user's settings before we hand things over. Currently, our only recourse is to reset a user's password and log in ourselves, but this is less than ideal, particularly if the user has already set their own passwords, etc.

My question is this: for Catalyst, has anyone come across a method of impersonating a user account such that, given the correct super-admin privileges, one could impersonate another account temporarily while testing out a setting, and then back out once done?

If not in Catalyst, then how have people approached this in other frameworks, or their own custom solutions? Admittedly, this is something that introduces a potentially egregious attack vector for a web application, but if forced to implement, how have people approached design for this? Perhaps some serious cookie-session-fu? Or possibly an actualID/effectiveID system?

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

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

发布评论

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

评论(1

孤凫 2024-10-26 07:24:10

我们使用自定义身份验证器控制器、自定义用户类 (MyApp::Core::User) 和几个领域:

package MyApp::Controller::Auth;
...
sub surrogate : Local {
    my ( $self, $c ) = @_;
    my $p = $c->req->params;
    my $actual_user = $c->user; # save it for later

    try {
        $c->authenticate({ id=>$p->{surrogate_id} }, 'none');
        $c->session->{user} = new MyApp::Core::User( 
             active_user    => $actual_user, 
             effective_user => $c->user );
        $c->stash->{json} = { success => \1, msg => "Login Ok" };
    } catch {
        $c->stash->{json} = { success => \0, msg => "Invalid User" };
    };
    $c->forward('View::JSON');  
}

myapp.conf 中,我使用如下内容:

<authentication>
    default_realm ldap
    <realms>
        <ldap>
             # ldap realm config stuff here
        </local>
        <none>
            <credential>
                class Password
                password_field password
                password_type none
            </credential>
            <store>
                class Null
            </store>
        </none>
     </realms>
</authentication>

这样我们就创建了一个普通的 Catalyst user 对象,但将其包装在我们的自定义用户类周围以获得更多控制。我可能可以创建一个专门的代理领域,但我选择使用我自己的用户类。这是不久前完成的,我还记得我们为什么这样做。

We use a custom authenticator controller, a custom user class (MyApp::Core::User) and several realms:

package MyApp::Controller::Auth;
...
sub surrogate : Local {
    my ( $self, $c ) = @_;
    my $p = $c->req->params;
    my $actual_user = $c->user; # save it for later

    try {
        $c->authenticate({ id=>$p->{surrogate_id} }, 'none');
        $c->session->{user} = new MyApp::Core::User( 
             active_user    => $actual_user, 
             effective_user => $c->user );
        $c->stash->{json} = { success => \1, msg => "Login Ok" };
    } catch {
        $c->stash->{json} = { success => \0, msg => "Invalid User" };
    };
    $c->forward('View::JSON');  
}

In myapp.conf I use something like this:

<authentication>
    default_realm ldap
    <realms>
        <ldap>
             # ldap realm config stuff here
        </local>
        <none>
            <credential>
                class Password
                password_field password
                password_type none
            </credential>
            <store>
                class Null
            </store>
        </none>
     </realms>
</authentication>

That way we're creating a normal Catalyst user object, but wrapping it around our custom user class for more control. I probably could have created an specialized realm for surrogating, but I've chosen using my own user class instead. It was done a while back and I can recall why we did it that way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文