version 1.93, 2006/08/29 20:04:41
|
version 1.100, 2006/09/19 18:03:02
|
Line 44 sub cleanup {
|
Line 44 sub cleanup {
|
my ($r)=@_; |
my ($r)=@_; |
if (! $r->is_initial_req()) { return DECLINED; } |
if (! $r->is_initial_req()) { return DECLINED; } |
&Apache::lonnet::save_cache(); |
&Apache::lonnet::save_cache(); |
|
&Apache::lontexconvert::jsMath_reset(); |
return OK; |
return OK; |
} |
} |
|
|
Line 137 sub get_posted_cgi {
|
Line 138 sub get_posted_cgi {
|
$r->headers_in->unset('Content-length'); |
$r->headers_in->unset('Content-length'); |
} |
} |
|
|
|
# handle the case of the single sign on user, at this point $r->user |
|
# will be set and valid now need to find the loncapa user info and possibly |
|
# balance them |
|
# returns OK if it was a SSO and user was handled |
|
# undef if not SSO or no means to hanle the user |
|
sub sso_login { |
|
my ($r,$lonid,$handle) = @_; |
|
|
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
|
if (!($r->user |
|
&& (!defined($env{'user.name'}) && !defined($env{'user.domain'})) |
|
&& (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq ''))) { |
|
# not an SSO case or already logged in |
|
return undef; |
|
} |
|
|
|
my ($user) = ($r->user =~ m/([a-zA-Z0-9_\-@.]*)/); |
|
|
|
my $domain = $r->dir_config('lonDefDomain'); |
|
my $home=&Apache::lonnet::homeserver($user,$domain); |
|
if ($home !~ /(con_lost|no_host|no_such_host)/) { |
|
if ($r->dir_config("lonBalancer") eq 'yes') { |
|
# login but immeaditly go to switch server to find us a new |
|
# machine |
|
&Apache::lonauth::success($r,$user,$domain,$home,'noredirect'); |
|
$r->internal_redirect('/adm/switchserver'); |
|
} else { |
|
# need to login them in, so generate the need data that |
|
# migrate expects to do login |
|
my %info=('ip' => $r->connection->remote_ip(), |
|
'domain' => $domain, |
|
'username' => $user, |
|
'server' => $r->dir_config('lonHostID'), |
|
'sso.login' => 1 |
|
); |
|
my $token = |
|
&Apache::lonnet::tmpput(\%info, |
|
$r->dir_config('lonHostID')); |
|
$env{'form.token'} = $token; |
|
$r->internal_redirect('/adm/migrateuser'); |
|
} |
|
return OK; |
|
} elsif (defined($r->dir_config('lonSSOUserUnknownRedirect'))) { |
|
$r->internal_redirect($r->dir_config('lonSSOUserUnknownRedirect')); |
|
return OK; |
|
} |
|
return undef; |
|
} |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
my $requrl=$r->uri; |
my $requrl=$r->uri; |
Line 151 sub handler {
|
Line 201 sub handler {
|
$handle=~s/\W//g; |
$handle=~s/\W//g; |
} |
} |
|
|
my ($sso_login); |
my $result = &sso_login($r,$lonid,$handle); |
if ($r->user |
if (defined($result)) { |
#&& $r->user ne 'lonadm' |
return $result |
&& (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) { |
|
&Apache::lonnet::logthis("$handle and -e ".(-e "$lonidsdir/$handle.id")); |
|
|
|
my $domain = $r->dir_config('lonDefDomain'); |
|
my $home=&Apache::lonnet::homeserver($r->user,$domain); |
|
if ($home !~ /(con_lost|no_host|no_such_host)/) { |
|
my %info=('ip' => $r->connection->remote_ip(), |
|
'domain' => $domain, |
|
'username' => $r->user, |
|
'server' => $r->dir_config('lonHostID'), |
|
'sso.login' => 1 |
|
); |
|
my $token = &Apache::lonnet::tmpput(\%info, |
|
$r->dir_config('lonHostID')); |
|
$env{'form.token'} = $token; |
|
$r->internal_redirect('/adm/migrateuser'); |
|
return OK; |
|
} elsif (defined($r->dir_config('lonSSOUserUnkownRedirect'))) { |
|
$r->internal_redirect($r->dir_config('lonSSOUserUnkownRedirect')); |
|
return OK; |
|
} |
|
} |
} |
|
|
|
|
if ($r->dir_config("lonBalancer") eq 'yes') { |
if ($r->dir_config("lonBalancer") eq 'yes') { |
$r->set_handlers('PerlResponseHandler'=> |
$r->set_handlers('PerlResponseHandler'=> |
[\&Apache::switchserver::handler]); |
[\&Apache::switchserver::handler]); |
Line 213 sub handler {
|
Line 243 sub handler {
|
|
|
# ---------------------------------------------------------------- Check access |
# ---------------------------------------------------------------- Check access |
my $now = time; |
my $now = time; |
if ($requrl!~/^\/adm|public|prtspool\//) { |
if ($requrl !~ m{^/(?:adm|public|prtspool)/} |
|
|| $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) { |
my $access=&Apache::lonnet::allowed('bre',$requrl); |
my $access=&Apache::lonnet::allowed('bre',$requrl); |
if ($access eq '1') { |
if ($access eq '1') { |
$env{'user.error.msg'}="$requrl:bre:0:0:Choose Course"; |
$env{'user.error.msg'}="$requrl:bre:0:0:Choose Course"; |