Skip to content

Commit

Permalink
Item12059: CasLogin should allow login by email, but retail the non-e…
Browse files Browse the repository at this point in the history
…mail loginname

git-svn-id: http://svn.foswiki.org/trunk/CasLoginContrib@15347 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Aug 29, 2012
1 parent a444d21 commit f3c152b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
7 changes: 7 additions & 0 deletions lib/Foswiki/Contrib/CasLoginContrib/Config.spec
Expand Up @@ -25,3 +25,10 @@ $Foswiki::cfg{CAS}{LogoutFromCAS} = $FALSE;
# specify the SSL ciphers to use when contacting the CAS server
# if you are having SSL connection issues, setting this to 'SSLv3' may help
$Foswiki::cfg{CAS}{SSL_version} = '';

# **BOOLEAN**
# Allow a user to log in to foswiki using the email addresses known to the password
# system.
$Foswiki::cfg{CAS}{AllowLoginUsingEmailAddress} = 0;


33 changes: 18 additions & 15 deletions lib/Foswiki/LoginManager/CasLogin.pm
Expand Up @@ -87,26 +87,28 @@ sub loadSession {
#print STDERR "hello : $authUser\n";
#print STDERR "params: ".join(', ', $query->param())."\n";
#print STDERR "uri: $uri\n";
#print STDERR "relative ".$query->url(-relative=>1);
#print STDERR "full ".$query->url(-full=>1);
#print STDERR "query ".$query->url(-query=>1);
#print STDERR "relative ".$query->url(-relative=>1);
#print STDERR "full ".$query->url(-full=>1);
#print STDERR "query ".$query->url(-query=>1);
#check returned ticket
if ( defined($ticket) ) {
$uri =~ s/[?;&]ticket=.*$//;
my $casUser = $this->{CAS}->validateST( $uri, $ticket );
if ($casUser) {
$authUser = $casUser;
# print STDERR "login? $authUser => $ticket\n";
#TODO: protect against auth as basemapper admin?

#if its an email address, we can make the generated wikiname more usefull
$authUser =~ s/(\.|@)(.)/$1.uc($2)/ge;
$authUser = ucfirst($authUser);
if ( $Foswiki::cfg{CAS}{AllowLoginUsingEmailAddress}
&& $casUser =~ /@/ )
{
my $login = $foswiki->{users}->findUserByEmail($casUser);
$casUser = $login->[0] if ( defined( $login->[0] ) );
}

$authUser = $casUser;
$this->userLoggedIn($authUser);
} else {
# a bad ticket - so ignore
# its a bit difficult if its a resubmit of an old ticket to the login script :/
}
else {

# a bad ticket - so ignore
# its a bit difficult if its a resubmit of an old ticket to the login script :/
}
}
else {
Expand All @@ -122,9 +124,10 @@ sub loadSession {
if ( $foswiki->inContext('login') || $foswiki->inContext('logon') )
{
if ( !$this->forceAuthentication() ) {
my $full = $query->url(-full=>1);
my $full = $query->url( -full => 1 );
$uri =~ s/^$full//;
$uri = Foswiki::Func::getScriptUrl(undef, undef, 'view').$uri;
$uri = Foswiki::Func::getScriptUrl( undef, undef, 'view' )
. $uri;
$foswiki->redirect( $uri, 0 );
}
}
Expand Down

0 comments on commit f3c152b

Please sign in to comment.