Commit ac47c65a authored by Clément OUDOT's avatar Clément OUDOT

AuthCAS: remove unused parameters and add debug information (#146)

parent f4514c41
......@@ -405,11 +405,8 @@ sub struct {
# CAS
casParams => {
_nodes =>
[qw(CAS_url CAS_loginUrl CAS_validationUrl CAS_CAFile)],
_nodes => [qw(CAS_url CAS_CAFile)],
CAS_url => 'text:/CAS_url',
CAS_loginUrl => 'text:/CAS_loginUrl',
CAS_validationUrl => 'text:/CAS_validationUrl',
CAS_CAFile => 'text:/CAS_CAFile',
},
......@@ -1300,8 +1297,6 @@ sub testStruct {
# CAS
CAS_url => $testNotDefined,
CAS_loginUrl => $testNotDefined,
CAS_validationUrl => $testNotDefined,
CAS_CAFile => $testNotDefined,
# Remote
......
......@@ -72,10 +72,8 @@ sub en {
dbiUserUser => 'User',
deleteSession => 'Delete session',
CAS_CAFile => 'CA file',
CAS_loginUrl => 'Login URL',
casParams => 'CAS parameters',
CAS_url => 'Server URL',
CAS_validationUrl => 'Validation URL',
cda => 'Multiple domains',
clickHereToForce => 'Click here to force',
Configuration => 'Configuration',
......@@ -362,10 +360,8 @@ sub fr {
dbiUserUser => 'Utilisateur',
deleteSession => 'Effacer la session',
CAS_CAFile => 'Fichier d\'AC',
CAS_loginUrl => 'URL d\'authentification',
casParams => 'Paramètres CAS',
CAS_url => 'URL du serveur',
CAS_validationUrl => 'URL de validation',
cda => 'Domaines multiples',
clickHereToForce => 'Cliquer ici pour forcer',
Configuration => 'Configuration',
......
......@@ -8,7 +8,7 @@ package Lemonldap::NG::Portal::AuthCAS;
use strict;
use Lemonldap::NG::Portal::Simple;
our $VERSION = '0.13';
our $VERSION = '0.20';
## @apmethod int authInit()
# Try to load AuthCAS perl module
......@@ -37,27 +37,37 @@ sub extractFormInfo {
CAFile => $self->{CAS_CAFile},
);
my $casLoginUrl = $self->{CAS_loginUrl};
my $casValidationUrl = $self->{CAS_validationUrl};
# Local URL
my $local_url = $self->url();
# Add URL parameter if present
if ( $self->{_url} ) {
my $url_param = 'url=' . $self->{_url};
$casLoginUrl .= ( $casLoginUrl =~ /\?/ ? '&' : '?' ) . $url_param;
$casValidationUrl .=
( $casValidationUrl =~ /\?/ ? '&' : '?' ) . $url_param;
$local_url .= ( $local_url =~ /\?/ ? '&' : '?' ) . $url_param;
}
my $login_url = $cas->getServerLoginURL($casLoginUrl);
# Build login URL
my $login_url = $cas->getServerLoginURL($local_url);
# Check Service Ticket
my $ticket = $self->param('ticket');
# Unless a ticket has been found, we redirect the user
unless ( $self->{user} = $cas->validateST( $casValidationUrl, $ticket ) ) {
print $self->redirect(
-uri => $login_url,
-status => '303 See Other'
);
exit;
unless ($ticket) {
$self->lmLog( "Redirect user to $login_url", 'debug' );
$self->{urldc} = $login_url;
return $self->_subProcess(qw(autoRedirect));
}
# Ticket found, try to validate it
unless ( $self->{user} = $cas->validateST( $local_url, $ticket ) ) {
$self->lmLog( "CAS error: " . &AuthCAS::get_errors(), 'error' );
return PE_ERROR;
}
else {
$self->lmLog( "CAS user found: " . $self->{user}, 'debug' );
}
PE_OK;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment