LEMONLDAP::NG : new feature: authentication via CAS
This commit is contained in:
parent
403d9bc2bd
commit
8852e3db5d
|
@ -1,5 +1,8 @@
|
|||
Revision history for Perl extension Lemonldap::NG::Portal.
|
||||
|
||||
0.63 Thu Feb 2 20:44:43
|
||||
- Adding CAS authentication compatibility system
|
||||
|
||||
0.62 Wed Feb 28 23:22:14
|
||||
- Adding cross-domain-authentication mechanism
|
||||
- local configuration overrides global configuration
|
||||
|
|
|
@ -2,6 +2,7 @@ Changes
|
|||
example/index.pl
|
||||
example/slavePortal.pl
|
||||
lib/Lemonldap/NG/Portal.pm
|
||||
lib/Lemonldap/NG/Portal/AuthCAS.pm
|
||||
lib/Lemonldap/NG/Portal/AuthLA.pm
|
||||
lib/Lemonldap/NG/Portal/AuthSSL.pm
|
||||
lib/Lemonldap/NG/Portal/CDA.pm
|
||||
|
@ -12,6 +13,7 @@ Makefile.PL
|
|||
MANIFEST
|
||||
META.yml Module meta-data (added by MakeMaker)
|
||||
README
|
||||
t/Lemonldap-NG-Portal-AuthCAS.t
|
||||
t/Lemonldap-NG-Portal-AuthSSL.t
|
||||
t/Lemonldap-NG-Portal-CDA.t
|
||||
t/Lemonldap-NG-Portal-SharedConf-DBI.t
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
package Lemonldap::NG::Portal::AuthCAS;
|
||||
|
||||
use strict;
|
||||
use Lemonldap::NG::Portal::Simple;
|
||||
use AuthCAS;
|
||||
|
||||
our $VERSION = '0.01';
|
||||
|
||||
our $OVERRIDE = {
|
||||
# By default, authentication is valid if SSL_CLIENT_S_DN_Email environement
|
||||
# variable is present. Adapt it if you want
|
||||
extractFormInfo => sub {
|
||||
my $self = shift;
|
||||
my $cas = new AuthCAS(casUrl => $self->{CAS_url},
|
||||
CAFile => $self->{CAS_CAFile},
|
||||
);
|
||||
my $login_url = $cas->getServerLoginURL($self->{CAS_loginUrl});
|
||||
|
||||
my $ticket = $self->param('ticket');
|
||||
# Unless a ticket has been found, we redirect the user
|
||||
unless( $self->{user} = $cas->validateST($self->{CAS_validationUrl}, $ticket) ) {
|
||||
print $self->SUPER::redirect(
|
||||
-uri => $login_url,
|
||||
-status => '302 Moved Temporary'
|
||||
);
|
||||
exit;
|
||||
}
|
||||
PE_OK;
|
||||
},
|
||||
|
||||
authenticate => sub {
|
||||
PE_OK;
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Lemonldap::NG::Portal::AuthCAS - Perl extension for building Lemonldap::NG
|
||||
compatible portals with CAS authentication. EXPERIMENTAL AND NOT FINISHED!
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Lemonldap::NG::Portal::SharedConf;
|
||||
my $portal = new Lemonldap::NG::Portal::Simple(
|
||||
configStorage => {...}, # See Lemonldap::NG::Portal
|
||||
authentication => 'CAS',
|
||||
CAS_url => 'https://cas.myserver',
|
||||
CAS_CAFile => '/etc/httpd/conf/ssl.crt/ca-bundle.crt',
|
||||
CAS_loginUrl => 'http://myserver/app.cgi',
|
||||
CAS_validationUrl => 'http://myserver/app.cgi',
|
||||
);
|
||||
|
||||
if($portal->process()) {
|
||||
# Write here the menu with CGI methods. This page is displayed ONLY IF
|
||||
# the user was not redirected here.
|
||||
print $portal->header; # DON'T FORGET THIS (see CGI(3))
|
||||
print "...";
|
||||
|
||||
# or redirect the user to the menu
|
||||
print $portal->redirect( -uri => 'https://portal/menu');
|
||||
}
|
||||
else {
|
||||
# If the user enters here, IT MEANS THAT CAS REDIRECTION DOES NOT WORK
|
||||
print $portal->header; # DON'T FORGET THIS (see CGI(3))
|
||||
print "<html><body><h1>Unable to work</h1>";
|
||||
print "This server isn't well configured. Contact your administrator.";
|
||||
print "</body></html>";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This library just overload few methods of Lemonldap::NG::Portal::Simple to use
|
||||
CAS mechanism: we've just try to get CAS ticket.
|
||||
|
||||
See L<Lemonldap::NG::Portal::Simple> for usage and other methods.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Lemonldap::NG::Portal>, L<Lemonldap::NG::Portal::Simple>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2007 by Xavier Guimard E<lt>x.guimard@free.frE<gt>
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.8.4 or,
|
||||
at your option, any later version of Perl 5 you may have available.
|
||||
|
||||
=cut
|
||||
|
|
@ -63,11 +63,11 @@ sub new {
|
|||
$self->{securedCookie} ||= 0;
|
||||
$self->{cookieName} ||= "lemonldap";
|
||||
|
||||
if ( $self->{authentication} eq "SSL" ) {
|
||||
require Lemonldap::NG::Portal::AuthSSL;
|
||||
if ( $self->{authentication} ne "ldap" ) {
|
||||
require "Lemonldap::NG::Portal::Auth".$self->{authentication};
|
||||
# $Lemonldap::NG::Portal::AuthSSL::OVERRIDE does not overload $self
|
||||
# variables: if the administrator has defined a sub, we respect it
|
||||
%$self = ( %$Lemonldap::NG::Portal::AuthSSL::OVERRIDE, %$self );
|
||||
%$self = ( %${"Lemonldap::NG::Portal::Auth".$self->{authentication}."::OVERRIDE"}, %$self );
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
|
21
modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthCAS.t
Normal file
21
modules/lemonldap-ng-portal/t/Lemonldap-NG-Portal-AuthCAS.t
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Before `make install' is performed this script should be runnable with
|
||||
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
|
||||
|
||||
#########################
|
||||
|
||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
||||
|
||||
use Test::More tests => 1;
|
||||
# SOAP::Lite is not required, so Lemonldap::NG::Manager::Conf::SOAP may
|
||||
# not run.
|
||||
SKIP: {
|
||||
eval { require AuthCAS };
|
||||
skip "AuthCAS is not installed, so CAS authentication will not work", 1 if($@);
|
||||
use_ok('Lemonldap::NG::Portal::AuthCAS');
|
||||
}
|
||||
|
||||
#########################
|
||||
|
||||
# Insert your test code below, the Test::More module is use()ed here so read
|
||||
# its man page ( perldoc Test::More ) for help writing this test script.
|
||||
|
Loading…
Reference in New Issue
Block a user