开发者

Authentication Module Issues with Apache 2 and Perl

I am SharePoint Developer trying to get a Perl module to work with Subversion, but I think something is wrong with my syntax. I just need to get the username and password, pass it into the webservic开发者_如何学Ce, get a true/false and authenticate based on that information. Here is the code to the module in 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;

If anyone has any suggestions please let me know. I am receiving an error like such in the Apache Config files: Can't call method "value" on an undefined value at C:/usr/site/lib/Apache2/AuthGetUser.pm line 30. Thanks for everything. If I get this to work I will have a blog post upcoming.


Try breaking down this line

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

For example does

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

work? How about:

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

with

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

where you define $pwdParam similarly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜