version 1.155, 2014/05/05 23:17:12
|
version 1.159.2.1, 2015/03/11 17:27:15
|
Line 283 sub sso_login {
|
Line 283 sub sso_login {
|
my ($r,$handle,$username) = @_; |
my ($r,$handle,$username) = @_; |
|
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
if (($r->user eq '') || ($username ne '') || |
if (($r->user eq '') || ($username ne '') || ($r->user eq 'public:public') || |
(defined($env{'user.name'}) && (defined($env{'user.domain'})) |
(defined($env{'user.name'}) && (defined($env{'user.domain'})) |
&& ($handle ne ''))) { |
&& ($handle ne ''))) { |
# not an SSO case or already logged in |
# not an SSO case or already logged in |
return undef; |
return undef; |
} |
} |
|
|
my ($user) = ($r->user =~ m/([a-zA-Z0-9_\-@.]*)/); |
my ($user) = ($r->user =~ m/^($match_username)$/); |
|
if ($user eq '') { |
|
return undef; |
|
} |
|
|
my $query = $r->args; |
my $query = $r->args; |
my %form; |
my %form; |
Line 307 sub sso_login {
|
Line 310 sub sso_login {
|
my %sessiondata; |
my %sessiondata; |
if ($form{'iptoken'}) { |
if ($form{'iptoken'}) { |
%sessiondata = &Apache::lonnet::tmpget($form{'iptoken'}); |
%sessiondata = &Apache::lonnet::tmpget($form{'iptoken'}); |
my $delete = &Apache::lonnet::tmpdel($form{'token'}); |
my $delete = &Apache::lonnet::tmpdel($form{'iptoken'}); |
|
unless ($sessiondata{'sessionserver'}) { |
|
delete($form{'iptoken'}); |
|
} |
} |
} |
|
|
my $domain = $r->dir_config('lonSSOUserDomain'); |
my $domain = $r->dir_config('lonSSOUserDomain'); |
Line 319 sub sso_login {
|
Line 325 sub sso_login {
|
&Apache::lonnet::logthis(" SSO authorized user $user "); |
&Apache::lonnet::logthis(" SSO authorized user $user "); |
my ($is_balancer,$otherserver,$hosthere); |
my ($is_balancer,$otherserver,$hosthere); |
if ($form{'iptoken'}) { |
if ($form{'iptoken'}) { |
if (($sessiondata{'domain'} eq $form{'udom'}) && |
if (($sessiondata{'domain'} eq $domain) && |
($sessiondata{'username'} eq $form{'uname'})) { |
($sessiondata{'username'} eq $user)) { |
$hosthere = 1; |
$hosthere = 1; |
} |
} |
} |
} |
Line 361 sub sso_login {
|
Line 367 sub sso_login {
|
'server' => $r->dir_config('lonHostID'), |
'server' => $r->dir_config('lonHostID'), |
'sso.login' => 1 |
'sso.login' => 1 |
); |
); |
foreach my $item ('role','symb') { |
foreach my $item ('role','symb','iptoken') { |
if (exists($form{$item})) { |
if (exists($form{$item})) { |
$info{$item} = $form{$item}; |
$info{$item} = $form{$item}; |
} |
} |
Line 442 sub handler {
|
Line 448 sub handler {
|
my ($is_balancer,$otherserver); |
my ($is_balancer,$otherserver); |
|
|
if ($handle eq '') { |
if ($handle eq '') { |
unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) { |
unless ((($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) || |
|
($requrl =~ m{^/public/$match_domain/$match_courseid/syllabus}) || |
|
($requrl =~ m{^/adm/help/}) || |
|
($requrl =~ m{^/res/$match_domain/$match_username/})) { |
$r->log_reason("Cookie not valid", $r->filename); |
$r->log_reason("Cookie not valid", $r->filename); |
} |
} |
} elsif ($handle ne '') { |
} elsif ($handle ne '') { |
Line 473 sub handler {
|
Line 482 sub handler {
|
} |
} |
$env{'request.filename'} = $r->filename; |
$env{'request.filename'} = $r->filename; |
$env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl); |
$env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl); |
my $suppext; |
my ($suppext,$checkabsolute); |
if ($requrl =~ m{^/adm/wrapper/ext/}) { |
if ($requrl =~ m{^/adm/wrapper/ext/}) { |
my $query = $r->args; |
my $query = $r->args; |
if ($query) { |
if ($query) { |
Line 494 sub handler {
|
Line 503 sub handler {
|
$env{'request.external.querystring'} = $preserved; |
$env{'request.external.querystring'} = $preserved; |
} |
} |
} |
} |
|
if ($env{'request.course.id'}) { |
|
$checkabsolute = 1; |
|
} |
} elsif ($env{'request.course.id'} && |
} elsif ($env{'request.course.id'} && |
(($requrl =~ m{^/adm/$match_domain/$match_username/aboutme$}) || |
(($requrl =~ m{^/adm/$match_domain/$match_username/aboutme$}) || |
($requrl =~ m{^/public/$cdom/$cnum/syllabus$}))) { |
($requrl =~ m{^/public/$cdom/$cnum/syllabus$}))) { |
Line 508 sub handler {
|
Line 520 sub handler {
|
} |
} |
} |
} |
} |
} |
|
if ($requrl =~ m{^/public/$cdom/$cnum/syllabus$}) { |
|
$checkabsolute = 1; |
|
} |
|
} |
|
if ($checkabsolute) { |
|
my $hostname = $r->hostname(); |
|
my $lonhost = &Apache::lonnet::host_from_dns($hostname); |
|
if ($lonhost) { |
|
my $actual = &Apache::lonnet::absolute_url($hostname); |
|
my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname; |
|
unless ($actual eq $expected) { |
|
$env{'request.use_absolute'} = $expected; |
|
} |
|
} |
} |
} |
# -------------------------------------------------------- Load POST parameters |
# -------------------------------------------------------- Load POST parameters |
|
|
Line 546 sub handler {
|
Line 572 sub handler {
|
if ($requrl !~ m{^/(?:adm|public|prtspool)/} |
if ($requrl !~ m{^/(?:adm|public|prtspool)/} |
|| $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) { |
|| $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) { |
my $access=&Apache::lonnet::allowed('bre',$requrl); |
my $access=&Apache::lonnet::allowed('bre',$requrl); |
|
if ($handle eq '') { |
|
unless ($access eq 'F') { |
|
if ($requrl =~ m{^/res/$match_domain/$match_username/}) { |
|
$r->log_reason("Cookie not valid", $r->filename); |
|
} |
|
} |
|
} |
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"; |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |