【问题标题】:Authentication Module Issues with Apache 2 and PerlApache 2 和 Perl 的身份验证模块问题
【发布时间】:2010-01-11 16:21:31
【问题描述】:

我是 SharePoint 开发人员,试图让 Perl 模块与 Subversion 一起使用,但我认为我的语法有问题。我只需要获取用户名和密码,将其传递给 Web 服务,获取真/假并根据该信息进行身份验证。下面是 Perl 模块的代码:

package Apache2::AuthGetUser; #authenticates users based on bool value from a asmx webservice
use SOAP::Lite;
use Data::Dumper;
use strict;
use warnings;
use Apache2::Access();
use Apache2::RequestRec();
use Apache2::Const ':common';

sub handler {
    my $r = shift;
    my $username = $r->user;
    my ($status, $password) = $r->get_basic_auth_pw;
    return $status unless $status == Apache2::Const::OK;

    my $endpoint = "http://localhost:2010/CIM.FBAAuthentication/12/template/layouts/wsFBAAuthentication.asmx"; #endpoint
    my $namespace = "http://tempuri.org/"; #namespace
    my $wsfunction = "AuthenticateUser"; #webservice function
    my $webservice = SOAP::Lite
        ->uri($namespace)
        ->on_action(sub { join '/', $namespace, $_[1] })
        ->proxy($endpoint);

    #my $method = SOAP::Data->name($wsfunction)
    my $method = SOAP::Data->name($wsfunction)
      ->attr({xmlns => $namespace});


    my @params = (SOAP::Data->name('UserName')->value($username)->type(''), SOAP::Data->name('Password')->value($password)->type(''));

    my $result = $webservice->call($method=>@params)->result;
    if($result ne "true"){
          $r->note_basic_auth_failure;
          #$r->log_reason($result);
          return AUTH_REQUIRED;
    }

    return Apache2::Const::OK;

}
1;

如果有人有任何建议,请告诉我。我在 Apache Config 文件中收到类似的错误:Can't call method "value" on an undefined value at C:/usr/site/lib/Apache2/AuthGetUser.pm 第 30 行。感谢您所做的一切。如果我能做到这一点,我将有一篇博文即将发布。

【问题讨论】:

  • 还有一些棘手的事情仍在发生,可能是顶部区域获取用户名...我尝试输入 $r->user('user') 但我认为它没有帮助...打破它并添加类型可能也做了一些事情,但还没有完全存在。

标签: perl svn mod-perl2 apache2-module


【解决方案1】:

尝试分解这条线

 my @params = (SOAP::Data->name('UserName')->value($username)->type(''), SOAP::Data->name('Password')->value($password)->type(''));

例如

 my $userParam = SOAP::Data->name('UserName')->value($username)->type('xsd:string');

工作?怎么样:

 my $userParam = SOAP::Data->new(name => 'UserName', value => $username, type => 'xsd:string');

 my @params = ($userParam, $pwdParam);

你定义 $pwdParam 的地方类似。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-23
    • 2016-04-02
    • 2014-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-10
    • 2014-11-17
    相关资源
    最近更新 更多