File:
[LON-CAPA] /
loncom /
auth /
lonrelaunch.pm
Revision
1.4:
download - view:
text,
annotated -
select for diffs
Wed Aug 24 20:58:50 2022 UTC (23 months, 3 weeks ago) by
raeburn
Branches:
MAIN
CVS tags:
version_2_12_X,
version_2_11_4_msu,
HEAD
- Dual SSO and non-SSO login from /adm/login
- Display of domain configuration for each server split into two tables
so input textboxes can be longer.
- "Pop-up if iframe" (Y/N) item added. If Y, when login page is in an
iframe, SSO log-in dialog will be displayed in a new window, i.e.,
not within the iframe, e.g., to satisfy sameorigin requirement in
x-frame-options in header sent by SSO server.
1: # The LearningOnline Network
2: # Re-launch guidance for deep linked access with username mismatch
3: #
4: # $Id: lonrelaunch.pm,v 1.4 2022/08/24 20:58:50 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonrelaunch;
30:
31: use strict;
32: use lib '/home/httpd/lib/perl/';
33: use Apache::Constants qw(:common :http REDIRECT);
34: use Apache::lonnet;
35: use Apache::loncommon();
36: use Apache::lonlocal;
37: use LONCAPA qw(:DEFAULT :match);
38: use CGI::Cookie();
39:
40: sub handler {
41: my $r = shift;
42:
43: my %data;
44: if ($r->args) {
45: &Apache::loncommon::get_unprocessed_cgi($r->args,['rtoken']);
46: if (exists($env{'form.rtoken'})) {
47: %data = &Apache::lonnet::tmpget($env{'form.rtoken'});
48: }
49: }
50: my $handle = &Apache::lonnet::check_for_valid_session($r);
51: if ($handle ne '') {
52: my $lonidsdir=$r->dir_config('lonIDsDir');
53: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
54: if (unlink("$lonidsdir/$handle.id")) {
55: if (($env{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
56: (-l "$lonidsdir/$env{'user.linkedenv'}.id") &&
57: (readlink("$lonidsdir/$env{'user.linkedenv'}.id") eq "$lonidsdir/$handle.id")) {
58: unlink("$lonidsdir/$env{'user.linkedenv'}.id");
59: }
60: }
61: my %temp=('logout' => time);
62: my $ip = &Apache::lonnet::get_requestor_ip();
63: &Apache::lonnet::put('email_status',\%temp);
64: &Apache::lonnet::log($env{'user.domain'},
65: $env{'user.name'},
66: $env{'user.home'},
67: "Logout $ip");
68: #expire the cookies
69: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
70: foreach my $name (keys(%cookies)) {
71: next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
72: my $c = new CGI::Cookie(-name => $name,
73: -value => '',
74: -expires => '-10y',);
75: $r->headers_out->add('Set-cookie' => $c);
76: }
77: }
78: if (!$Apache::lonlocal::lh) {
79: &Apache::lonlocal::get_language_handle($r);
80: }
81: &Apache::loncommon::content_type($r,'text/html');
82: $r->send_http_header;
83: return OK if $r->header_only;
84:
85: if ((keys(%data)) && ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$})) {
86: my $url = $data{'origurl'};
87: if ($data{'linkprot'} =~ m{^\w+(c|d):\Q$url\E$}) {
88: if ((!exists($data{'linkprotuser'})) ||
89: (($data{'linkprotuser'}) &&
90: ($data{'linkprotuser'} =~ m{^($match_username):($match_domain)$}))) {
91: $url .= '?ltoken='.$env{'form.rtoken'};
92: $r->print(&Apache::loncommon::start_page('Updating session',undef,
93: {'only_body' => 1,
94: 'redirect' => [1,$url,'',$data{'lcssowin'}]}).
95: '<p>'.&mt('Updating old session information').'</p>'.
96: &Apache::loncommon::end_page());
97: return OK;
98: }
99: }
100: }
101: my $args = {'only_body' => 1};
102: if ($data{'lcssowin'}) {
103: $args->{'redirect'} = [1,$data{'origurl'},'',$data{'lcssowin'}];
104: }
105: if ($data{'linkprot'}) {
106: $r->print(&Apache::loncommon::start_page('Updating session',undef,$args));
107: if ($data{'linkprotuser'} ne '') {
108: $r->print(&mt('Although your credentials were authenticated, the username you entered did not match what was expected [_1] from the link you followed',"($data{'linkprotuser'})"));
109: } else {
110: $r->print(&mt('Expired any existing session'));
111: }
112: } else {
113: $r->print(&Apache::loncommon::start_page('Session removed',undef,$args));
114: $r->print(&mt('Expired any existing session'));
115: }
116: $r->print(&Apache::loncommon::end_page());
117: if (exists($env{'form.rtoken'})) {
118: &Apache::lonnet::tmpdel($env{'form.rtoken'});
119: }
120: return OK;
121: }
122:
123: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>