OpenID-2 in progress (#595)
This commit is contained in:
parent
e4bf8ac619
commit
7805387aff
|
@ -129,7 +129,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "llng-fastcgi-server 1"
|
||||
.TH llng-fastcgi-server 1 "2017-01-02" "perl v5.24.1" "User Contributed Perl Documentation"
|
||||
.TH llng-fastcgi-server 1 "2017-01-05" "perl v5.24.1" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
|
|
@ -50,8 +50,6 @@ has ua => (
|
|||
|
||||
# TODO : LWP options to use a proxy for example
|
||||
my $ua = LWP::UserAgent->new();
|
||||
push @{ $ua->requests_redirectable }, 'POST';
|
||||
$ua->env_proxy();
|
||||
return $ua;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -76,11 +76,11 @@ sub forUnauthUser {
|
|||
return PE_OPENID_EMPTY;
|
||||
}
|
||||
if ( $mode eq 'associate' ) {
|
||||
return $self->_openIDResponse(
|
||||
return $self->_openIDResponse( $req,
|
||||
$self->openIDServer($req)->_mode_associate() );
|
||||
}
|
||||
elsif ( $mode eq 'check_authentication' ) {
|
||||
return $self->_openIDResponse(
|
||||
return $self->_openIDResponse( $req,
|
||||
$self->openIDServer($req)->_mode_check_authentication() );
|
||||
}
|
||||
return PE_OK;
|
||||
|
@ -103,7 +103,7 @@ sub run {
|
|||
return PE_ERROR;
|
||||
}
|
||||
my @r = $self->openIDServer($req)->_mode_checkid();
|
||||
return $self->_openIDResponse(@r);
|
||||
return $self->_openIDResponse( $req, @r );
|
||||
}
|
||||
|
||||
sub logout {
|
||||
|
@ -237,9 +237,7 @@ sub _openIDResponse {
|
|||
else {
|
||||
$req->response(
|
||||
$self->p->sendError(
|
||||
$req,
|
||||
'OpenID error ',
|
||||
$self->openIDServer($req)->err()
|
||||
$req, 'OpenID error ' . $self->openIDServer($req)->err()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -119,13 +119,13 @@ sub display {
|
|||
or $req->{error} == PE_OPENID_BADID )
|
||||
{
|
||||
$skinfile = 'openid';
|
||||
my $p = $self->{portal} . $self->{issuerDBOpenIDPath};
|
||||
$p =~ s#(?<!:)/\^?/#/#g;
|
||||
my $p = $self->conf->{portal} . $self->conf->{issuerDBOpenIDPath};
|
||||
$p =~ s#(?<!:)/?\^?/#/#g;
|
||||
%templateParams = (
|
||||
AUTH_ERROR => $self->error,
|
||||
AUTH_ERROR_TYPE => $req->error_type,
|
||||
PROVIDERURI => $p,
|
||||
ID => $self->{_openidPortal}
|
||||
ID => $req->datas->{_openidPortal}
|
||||
. $req->{sessionInfo}
|
||||
->{ $self->conf->{openIdAttr} || $self->conf->{whatToTrace} },
|
||||
PORTAL_URL => $self->conf->{portal},
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN {
|
|||
require 't/test-lib.pm';
|
||||
}
|
||||
|
||||
my $maintests = 4;
|
||||
my $maintests = 7;
|
||||
my $debug = 'debug';
|
||||
my ( $issuer, $sp, $res );
|
||||
my %handlerOR = ( issuer => [], sp => [] );
|
||||
|
@ -33,18 +33,44 @@ SKIP: {
|
|||
'Unauth SP request'
|
||||
);
|
||||
expectForm( $res, '#', undef );
|
||||
ok( $res->[2]->[0] =~ /name="openid_identifier"/, ' Found OpenID input' );
|
||||
ok( $res->[2]->[0] =~ /name="openid_identifier"/,
|
||||
' Ask for OpenID identity' );
|
||||
|
||||
my $query =
|
||||
'openid_identifier=http%3A%2F%2Fauth.idp.com%2Fopenidserver%2Fdwho';
|
||||
#ok(
|
||||
# $res = $sp->_post(
|
||||
# '/', IO::String->new($query), length => length($query),
|
||||
# ),
|
||||
# 'Post OpenID identity'
|
||||
#);
|
||||
|
||||
#print STDERR Dumper($res);
|
||||
ok(
|
||||
$res = $sp->_post(
|
||||
'/', IO::String->new($query),
|
||||
length => length($query),
|
||||
accept => 'text/html',
|
||||
),
|
||||
'Post OpenID identity'
|
||||
);
|
||||
my $uri;
|
||||
( $uri, $query ) = expectRedirection( $res,
|
||||
qr#http://auth.idp.com(/openidserver/?)\?(openid.*)$# );
|
||||
|
||||
# Follow redirection do IdP
|
||||
switch ('issuer');
|
||||
ok( $res = $issuer->_get( $uri, query => $query, accept => 'text/html' ),
|
||||
'Follow redirection to IdP' );
|
||||
expectOK($res);
|
||||
my ( $host, $tmp );
|
||||
( $host, $tmp, $query ) = expectForm( $res, '#', undef, 'openid.mode' );
|
||||
$query .= '&user=dwho&password=dwho';
|
||||
|
||||
# Try to authenticate
|
||||
ok(
|
||||
$res = $issuer->_post(
|
||||
$uri, IO::String->new($query),
|
||||
length => length($query),
|
||||
accept => 'text/html'
|
||||
),
|
||||
'Try to authenticate'
|
||||
);
|
||||
|
||||
#print STDERR Dumper($query);
|
||||
}
|
||||
|
||||
count($maintests);
|
||||
|
@ -66,7 +92,6 @@ sub LWP::UserAgent::request {
|
|||
my $url = $1;
|
||||
my ($res);
|
||||
count(1);
|
||||
print STDERR Dumper($req);
|
||||
if ( $req->method =~ /^post$/i ) {
|
||||
my $s = $req->content;
|
||||
ok(
|
||||
|
@ -74,24 +99,23 @@ sub LWP::UserAgent::request {
|
|||
$url, IO::String->new($s),
|
||||
length => length($s),
|
||||
type => $req->header('Content-Type'),
|
||||
accept => 'text/plain',
|
||||
),
|
||||
' Execute request'
|
||||
);
|
||||
}
|
||||
else {
|
||||
ok( $res = $issuer->_get( $url, ), ' Execute request' );
|
||||
ok( $res = $issuer->_get( $url, accept => 'text/plain', ),
|
||||
' Execute post request' );
|
||||
}
|
||||
expectOK($res);
|
||||
ok( getHeader( $res, 'Content-Type' ) =~ m#^application/json#,
|
||||
' Content is JSON' )
|
||||
or explain( $res->[1], 'Content-Type => application/json' );
|
||||
my $httpResp = HTTP::Response->new( $res->[0], 'OK' );
|
||||
|
||||
while ( my $name = shift @{ $res->[1] } ) {
|
||||
$httpResp->header( $name, shift( @{ $res->[1] } ) );
|
||||
}
|
||||
$httpResp->content( join( '', @{ $res->[2] } ) );
|
||||
count(2);
|
||||
count(1);
|
||||
return $httpResp;
|
||||
}
|
||||
|
||||
|
@ -121,6 +145,9 @@ sub sp {
|
|||
authentication => 'OpenID',
|
||||
userDB => 'OpenID',
|
||||
openIdSecret => 'qwerty',
|
||||
exportedVars => {
|
||||
mail => 'email',
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
@ -110,7 +110,7 @@ sub expectForm {
|
|||
count(1);
|
||||
}
|
||||
my %fields = ( $res->[2]->[0] =~
|
||||
m#<input.+?name="(.+?)".+?value="(.+?)"#gs );
|
||||
m#<input.+?name="(.+?)".+?value="(.*?)"#gs );
|
||||
my $query = join( '&',
|
||||
map { "$_=" . uri_escape( uri_unescape( $fields{$_} ) ) }
|
||||
keys(%fields) );
|
||||
|
|
Loading…
Reference in New Issue
Block a user