version 1.75, 2006/04/20 04:30:02
|
version 1.79, 2006/06/02 21:23:49
|
Line 29
|
Line 29
|
package Apache::lonauth; |
package Apache::lonauth; |
|
|
use strict; |
use strict; |
|
use LONCAPA; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::File; |
|
use CGI qw(:standard); |
use CGI qw(:standard); |
use CGI::Cookie(); |
use CGI::Cookie(); |
use DynaLoader; # for Crypt::DES version |
use DynaLoader; # for Crypt::DES version |
Line 88 sub success {
|
Line 88 sub success {
|
|
|
# Initialize roles |
# Initialize roles |
|
|
$userroles=Apache::lonnet::rolesinit($domain,$username,$authhost); |
$userroles=&Apache::lonnet::rolesinit($domain,$username,$authhost); |
} |
} |
# ------------------------------------ Check browser type and MathML capability |
# ------------------------------------ Check browser type and MathML capability |
|
|
Line 109 sub success {
|
Line 109 sub success {
|
} |
} |
# ------------------------------------------------------------- Get environment |
# ------------------------------------------------------------- Get environment |
|
|
my $userenv; |
|
my %userenv=Apache::lonnet::dump('environment',$domain,$username); |
my %userenv=Apache::lonnet::dump('environment',$domain,$username); |
my ($tmp) = keys(%userenv); |
my ($tmp) = keys(%userenv); |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
# default remote control to off |
# default remote control to off |
if ($userenv{'remote'} ne 'on') { $userenv{'remote'} = 'off'; } |
if ($userenv{'remote'} ne 'on') { $userenv{'remote'} = 'off'; } |
foreach my $key (keys(%userenv)) { |
} else { |
$userenv.="environment.$key=$userenv{$key}\n"; |
undef(%userenv); |
} |
|
} |
} |
if (($userenv{'interface'}) && (!$FORM{'interface'})) { |
if (($userenv{'interface'}) && (!$FORM{'interface'})) { |
$FORM{'interface'}=$userenv{'interface'}; |
$FORM{'interface'}=$userenv{'interface'}; |
Line 134 sub success {
|
Line 132 sub success {
|
# --------------------------------------------------------- Write first profile |
# --------------------------------------------------------- Write first profile |
|
|
{ |
{ |
my $idf=Apache::File->new(">$lonids/$cookie.id"); |
my %initial_env = |
unless (flock($idf,LOCK_EX)) { |
("user.name" => $username, |
&Apache::lonnet::logthis("<font color=blue>WARNING: ". |
"user.domain" => $domain, |
'Could not obtain exclusive lock in lonauth: '.$!); |
"user.home" => $authhost, |
$idf->close(); |
"browser.type" => $clientbrowser, |
return 'error: '.$!; |
"browser.version" => $clientversion, |
} |
"browser.mathml" => $clientmathml, |
if ($userenv ne '') { print $idf "$userenv\n"; } |
"browser.unicode" => $clientunicode, |
print $idf "user.name=$username\n"; |
"browser.os" => $clientos, |
print $idf "user.domain=$domain\n"; |
"server.domain" => $r->dir_config('lonDefDomain'), |
print $idf "user.home=$authhost\n"; |
"request.course.fn" => '', |
print $idf "browser.type=$clientbrowser\n"; |
"request.course.uri" => '', |
print $idf "browser.version=$clientversion\n"; |
"request.course.sec" => '', |
print $idf "browser.mathml=$clientmathml\n"; |
"request.role" => 'cm', |
print $idf "browser.unicode=$clientunicode\n"; |
"request.role.adv" => $env{'user.adv'}, |
print $idf "browser.os=$clientos\n"; |
"request.host" => $ENV{'REMOTE_ADDR'},); |
|
|
if ($FORM{'localpath'}) { |
if ($FORM{'localpath'}) { |
print $idf "browser.localpath=$FORM{'localpath'}\n"; |
$initial_env{"browser.localpath"} = $FORM{'localpath'}; |
print $idf "browser.localres=$FORM{'localres'}\n"; |
$initial_env{"browser.localres"} = $FORM{'localres'}; |
} |
} |
print $idf "server.domain=".$r->dir_config('lonDefDomain')."\n"; |
|
print $idf "request.course.fn=\n"; |
|
print $idf "request.course.uri=\n"; |
|
print $idf "request.course.sec=\n"; |
|
print $idf "request.role=cm\n"; |
|
print $idf "request.role.adv=$env{'user.adv'}\n"; |
|
print $idf "request.host=$ENV{'REMOTE_ADDR'}\n"; |
|
if ($public) { |
if ($public) { |
print $idf "environment.remote=off\n"; |
$initial_env{"environment.remote"} = "off"; |
} |
} |
if ($FORM{'interface'}) { |
if ($FORM{'interface'}) { |
$FORM{'interface'}=~s/\W//gs; |
$FORM{'interface'}=~s/\W//gs; |
print $idf "browser.interface=$FORM{'interface'}\n"; |
$initial_env{"browser.interface"} = $FORM{'interface'}; |
$env{'browser.interface'}=$FORM{'interface'}; |
$env{'browser.interface'}=$FORM{'interface'}; |
foreach ('imagesuppress','appletsuppress', |
foreach my $option ('imagesuppress','appletsuppress', |
'embedsuppress','fontenhance','blackwhite') { |
'embedsuppress','fontenhance','blackwhite') { |
if (($FORM{$_} eq 'true') || |
if (($FORM{$option} eq 'true') || |
($userenv{$_} eq 'on')) { |
($userenv{$option} eq 'on')) { |
print $idf "browser.$_=on\n"; |
$initial_env{"browser.$option"} = "on"; |
} |
} |
} |
} |
} |
} |
if ($userroles ne '') { print $idf "$userroles"; } |
|
$idf->close(); |
open(my $idf,">$lonids/$cookie.id"); |
|
unless (flock($idf,LOCK_EX)) { |
|
&Apache::lonnet::logthis("<font color=blue>WARNING: ". |
|
'Could not obtain exclusive lock in lonauth: '.$!); |
|
close($idf); |
|
return 'error: '.$!; |
|
} |
|
|
|
while (my ($key,$value) = each(%initial_env)) { |
|
print $idf (&escape($key).'='.&escape($value)."\n"); |
|
} |
|
while (my ($key,$value) = each(%userenv)) { |
|
print $idf (&escape('environment.'.$key).'='.&escape($value)."\n"); |
|
} |
|
while (my ($key,$value) = each(%{$userroles})) { |
|
print $idf (&escape($key).'='.&escape($value)."\n"); |
|
} |
|
close($idf); |
} |
} |
$env{'request.role'}='cm'; |
$env{'request.role'}='cm'; |
$env{'request.role.adv'}=$env{'user.adv'}; |
$env{'request.role.adv'}=$env{'user.adv'}; |
Line 208 sub success {
|
Line 218 sub success {
|
my $setflags=&Apache::lonmenu::setflags(); |
my $setflags=&Apache::lonmenu::setflags(); |
my $maincall=&Apache::lonmenu::maincall(); |
my $maincall=&Apache::lonmenu::maincall(); |
my $start_page=&Apache::loncommon::start_page('Successful Login', |
my $start_page=&Apache::loncommon::start_page('Successful Login', |
$startupremote); |
$startupremote, |
|
{'no_inline_link' => 1,}); |
my $end_page =&Apache::loncommon::end_page(); |
my $end_page =&Apache::loncommon::end_page(); |
|
|
my $continuelink; |
my $continuelink; |
Line 246 ENDSUCCESS
|
Line 257 ENDSUCCESS
|
|
|
sub failed { |
sub failed { |
my ($r,$message) = @_; |
my ($r,$message) = @_; |
my $start_page = &Apache::loncommon::start_page('Unsuccessful Login'); |
my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef, |
|
{'no_inline_link' => 1,}); |
my $end_page = &Apache::loncommon::end_page(); |
my $end_page = &Apache::loncommon::end_page(); |
|
|
my %lt=('sorry' => &mt('Sorry ...'), |
my %lt=('sorry' => &mt('Sorry ...'), |
Line 365 ENDFAILED
|
Line 377 ENDFAILED
|
failed($r,'Information needed to verify your login information is missing, inaccessible or expired.'); |
failed($r,'Information needed to verify your login information is missing, inaccessible or expired.'); |
return OK; |
return OK; |
} else { |
} else { |
unless (&Apache::lonnet::reply('tmpdel:'.$FORM{'logtoken'}, |
my $reply = &Apache::lonnet::reply('tmpdel:'.$FORM{'logtoken'}, |
$FORM{'serverid'}) eq 'ok') { |
$FORM{'serverid'}); |
|
if ( $reply ne 'ok' ) { |
&failed($r,'Session could not be opened.'); |
&failed($r,'Session could not be opened.'); |
|
&Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $FORM{'serverid'}." to get login token"); |
|
return OK; |
} |
} |
} |
} |
my ($key,$firsturl)=split(/&/,$tmpinfo); |
my ($key,$firsturl)=split(/&/,$tmpinfo); |