CAS in progress (#595)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 9 years ago
parent c0d8756192
commit 31496271ba
  1. 1
      lemonldap-ng-portal/MANIFEST
  2. 6
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/CAS.pm
  3. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/SAML.pm
  4. 106
      lemonldap-ng-portal/t/31-Auth-and-issuer-CAS.t
  5. 6
      lemonldap-ng-portal/t/lmConf-1.js

@ -361,6 +361,7 @@ t/30-Auth-and-issuer-SAML-POST-IdP-initiated.t
t/30-Auth-and-issuer-SAML-POST.t
t/30-Auth-and-issuer-SAML-Redirect-IdP-initiated.t
t/30-Auth-and-issuer-SAML-Redirect.t
t/31-Auth-and-issuer-CAS.t
t/40-Notifications-DBI.t
t/50-IssuerGet.t
t/90-translations.t

@ -1,4 +1,4 @@
package Lemonldap::NG::Portal::Auth::SAML;
package Lemonldap::NG::Portal::Auth::CAS;
use strict;
use Mouse;
@ -12,7 +12,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Portal::Auth::Base', 'Lemonldap::NG::Portal::Lib::SAML';
extends 'Lemonldap::NG::Portal::Auth::Base', 'Lemonldap::NG::Portal::Lib::CAS';
# PROPERTIES
@ -211,6 +211,8 @@ sub authLogout {
sub getDisplayType {
return "logo";
}
1;
__END__
=head1 NAME

@ -33,7 +33,7 @@ sub init {
return 1;
}
# RUNNONG METHODS
# RUNNING METHODS
# Does nothing
sub getUser {

@ -0,0 +1,106 @@
use Test::More;
use strict;
use IO::String;
use MIME::Base64;
BEGIN {
require 't/test-lib.pm';
}
my $maintests = 1;
my $debug = 'error';
my ( $issuer, $sp, $res );
my %handlerOR = ( issuer => [], sp => [] );
SKIP: {
eval "use AuthCAS";
if ($@) {
skip 'AuthCAS not found', $maintests;
}
#ok( $issuer = issuer(), 'Issuer portal' );
#$handlerOR{issuer} = \@Lemonldap::NG::Handler::Main::Reload::_onReload;
switch ('sp');
ok( $sp = sp(), 'SP portal' );
$handlerOR{sp} = \@Lemonldap::NG::Handler::Main::Reload::_onReload;
}
count($maintests);
clean_sessions();
done_testing( count() );
# Redefine LWP methods for tests
no warnings 'redefine';
sub LWP::UserAgent::request {
my ( $self, $req ) = @_;
ok( $req->uri =~ m#http://auth.sp.com(.*)#, 'Request from SP to IdP' );
my $url = $1;
my $res;
my $s = $req->content;
ok(
$res = $sp->_post(
$url, IO::String->new($s),
length => length($s),
type => 'application/xml',
),
'Execute request'
);
ok( ( $res->[0] == 200 or $res->[0] == 400 ), 'Response is 200 or 400' )
or explain( $res->[0], "200 or 400" );
ok( $issuer->getHeader( $res, 'Content-Type' ) =~ m#^application/xml#,
'Content is XML' )
or explain( $res->[1], 'Content-Type => application/xml' );
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(4);
return $httpResp;
}
sub switch {
my $type = shift;
@Lemonldap::NG::Handler::Main::Reload::_onReload = @{
$handlerOR{$type};
};
}
sub issuer {
return LLNG::Manager::Test->new(
{
ini => {
logLevel => $debug,
templatesDir => 'site/htdocs/static',
domain => 'idp.com',
portal => 'http://auth.idp.com',
authentication => 'Demo',
userDB => 'Demo',
issuerDBCASActivation => 1,
casAttr => 'uid',
casAttributes => { cn => 'cn', uid => 'uid', },
casAccessControlPolicy => 'none',
}
}
);
}
sub sp {
return LLNG::Manager::Test->new(
{
ini => {
logLevel => $debug,
domain => 'sp.com',
portal => 'http://auth.sp.com',
authentication => 'CAS',
userDB => 'Null',
issuerDBCASActivation => 0,
CASurl => 'http://auth.idp.com/cas/',
CASCAFile => 't/caFile.pem',
},
}
);
}

@ -54,6 +54,12 @@
"notifications": 0,
"passwordDB": "Null",
"portal": "http://auth.example.com/",
"casStorage": "Apache::Session::File",
"casStorageOptions": {
"Directory": "t/sessions/saml",
"LockDirectory": "t/sessions/saml/lock",
"generateModule": "Lemonldap::NG::Common::Apache::Session::Generate::SHA256"
},
"samlStorage": "Apache::Session::File",
"samlStorageOptions": {
"Directory": "t/sessions/saml",

Loading…
Cancel
Save