File:
[LON-CAPA] /
loncom /
auth /
lonlogin.pm
Revision
1.37:
download - view:
text,
annotated -
select for diffs
Sun Mar 2 02:16:53 2003 UTC (21 years, 3 months ago) by
www
Branches:
MAIN
CVS tags:
HEAD
Bug #1285
loncron cleans login tokens after a day.
* lonauth now give better error messages
* lonlogin refreshes the login page after a day
(so the "expired" error should never happen anyway)
* loginproblems was adapted
1: # The LearningOnline Network
2: # Login Screen
3: #
4: # $Id: lonlogin.pm,v 1.37 2003/03/02 02:16:53 www 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: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
29: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9,
30: # 1/17/01 Gerd Kortemeyer
31: #
32: # 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole
33: #
34: # 7/10/02 Jeremy Bowers
35:
36: package Apache::lonlogin;
37:
38: use strict;
39: use Apache::Constants qw(:common);
40: use Apache::File ();
41: use Apache::lonnet();
42: use Apache::loncommon();
43:
44: sub handler {
45: my $r = shift;
46: $r->content_type('text/html');
47: &Apache::loncommon::no_cache($r);
48: $r->send_http_header;
49: return OK if $r->header_only;
50:
51:
52: &Apache::loncommon::get_unprocessed_cgi
53: ($ENV{'QUERY_STRING'},['interface','username','domain','firsturl']);
54:
55: # ----------------------------------------------------------- Process Interface
56: $ENV{'form.interface'}=~s/\W//g;
57:
58: my $textbrowsers=$r->dir_config('lonTextBrowsers');
59: my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
60:
61: foreach (split(/\:/,$textbrowsers)) {
62: if ($httpbrowser=~/$_/i) {
63: $ENV{'form.interface'}='textual';
64: }
65: }
66:
67: my $fullgraph=($ENV{'form.interface'} ne 'textual');
68:
69: my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':8080'.
70: $r->dir_config('lonIconsURL');
71: my $domain = $r->dir_config('lonDefDomain');
72: my $role = $r->dir_config('lonRole');
73: my $loadlim = $r->dir_config('lonLoadLim');
74: my $servadm = $r->dir_config('lonAdmEMail');
75: my $sysadm = $r->dir_config('lonSysEMail');
76: my $lonhost = $r->dir_config('lonHostID');
77: my $tabdir = $r->dir_config('lonTabDir');
78: my $include = $r->dir_config('lonIncludes');
79: my $expire = $r->dir_config('lonExpire');
80:
81: # --------------------------------------------- Default values for login fields
82:
83: my $authusername=($ENV{'form.username'}?$ENV{'form.username'}:'');
84: my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain);
85:
86: # ---------------------------------------------------------- Determine own load
87: my $loadavg;
88: {
89: my $loadfile=Apache::File->new('/proc/loadavg');
90: $loadavg=<$loadfile>;
91: }
92: $loadavg =~ s/\s.*//g;
93: my $loadpercent=100*$loadavg/$loadlim;
94:
95: # ------------------------------------------------------- Do the load balancing
96: my $otherserver='http://'.$ENV{'SERVER_NAME'};
97: my $firsturl=
98: ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});
99: # ---------------------------------------- Are we access server and overloaded?
100: if (($role eq 'access') && ($loadpercent>100.0)) {
101: $otherserver=Apache::lonnet::spareserver($loadpercent);
102: }
103:
104: # -------------------------------------------------------- Set login parameters
105:
106: my @hexstr=('0','1','2','3','4','5','6','7',
107: '8','9','a','b','c','d','e','f');
108: my $lkey='';
109: for (0..7) {
110: $lkey.=$hexstr[rand(15)];
111: }
112:
113: my $ukey='';
114: for (0..7) {
115: $ukey.=$hexstr[rand(15)];
116: }
117:
118: my $lextkey=hex($lkey);
119: if ($lextkey>2147483647) { $lextkey-=4294967296; }
120:
121: my $uextkey=hex($ukey);
122: if ($uextkey>2147483647) { $uextkey-=4294967296; }
123:
124: # -------------------------------------------------------- Store away log token
125: my $logtoken=Apache::lonnet::reply(
126: 'tmpput:'.$ukey.$lkey.'&'.$firsturl,
127: $lonhost);
128:
129: # ------------------- If we cannot talk to ourselves, we are in serious trouble
130:
131: if ($logtoken eq 'con_lost') {
132: my $spares='';
133: foreach (keys %Apache::lonnet::hostname) {
134: if ($_ ne $lonhost) {
135: $spares.='<br /><a href="http://'.$Apache::lonnet::hostname{$_}.
136: '/adm/login?domain='.$authdomain.'">'.
137: $Apache::lonnet::hostname{$_}.'</a>';
138: if ($Apache::lonnet::spareid{$_}) {
139: $spares.=' (preferred)';
140: }
141: }
142: }
143: $r->print(<<ENDTROUBLE);
144: <html>
145: <head><title>The LearningOnline Network with CAPA</title></head>
146: <body bgcolor="#FFFFFF">
147: <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />
148: <h3>This LON-CAPA server is temporarily not available for login</h3>
149: <p>Please attempt to login to one of the following servers:</p>$spares
150: <p>If the problem persists, please contact <tt>$servadm</tt>.</p>
151: </body>
152: </html>
153: ENDTROUBLE
154: return OK;
155: }
156:
157: # ----------------------------------------------- Apparently we are in business
158:
159: my $domainlogo=&Apache::loncommon::domainlogo();
160: # --------------------------------------------------- Print login screen header
161: $r->print(<<ENDHEADER);
162: <html>
163: <head>
164: <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />
165: <title>The LearningOnline Network with CAPA Login</title>
166: </head>
167: ENDHEADER
168: # ---------------------------------------------------- Serve out DES JavaScript
169: {
170: my $jsh=Apache::File->new($include."/londes.js");
171: $r->print(<$jsh>);
172: }
173:
174: # ----------------------------------------------------------- Front page design
175: my $pgbg=
176: ($fullgraph?&Apache::loncommon::designparm('login.pgbg'):'#FFFFFF');
177: my $font=
178: ($fullgraph?&Apache::loncommon::designparm('login.font'):'#000000');
179: my $link=
180: ($fullgraph?&Apache::loncommon::designparm('login.link'):'#0000FF');
181: my $vlink=
182: ($fullgraph?&Apache::loncommon::designparm('login.vlink'):'#0000FF');
183: my $alink=&Apache::loncommon::designparm('login.alink');
184: my $mainbg=
185: ($fullgraph?&Apache::loncommon::designparm('login.mainbg'):'#FFFFFF');
186: my $sidebg=
187: ($fullgraph?&Apache::loncommon::designparm('login.sidebg'):'#FFFFFF');
188: my $logo=&Apache::loncommon::designparm('login.logo');
189: my $img=&Apache::loncommon::designparm('login.img');
190:
191:
192: # ---------------------------------------------------------- Serve rest of page
193: $r->print(<<ENDSCRIPT);
194:
195: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
196: topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
197:
198: <script language="JavaScript">
199: function send()
200: {
201: this.document.server.elements.uname.value
202: =this.document.client.elements.uname.value;
203:
204: this.document.server.elements.udom.value
205: =this.document.client.elements.udom.value;
206:
207: this.document.server.elements.imagesuppress.value
208: =this.document.client.elements.imagesuppress.checked;
209:
210: this.document.server.elements.embedsuppress.value
211: =this.document.client.elements.embedsuppress.checked;
212:
213: this.document.server.elements.appletsuppress.value
214: =this.document.client.elements.appletsuppress.checked;
215:
216: this.document.server.elements.fontenhance.value
217: =this.document.client.elements.fontenhance.checked;
218:
219: this.document.server.elements.blackwhite.value
220: =this.document.client.elements.blackwhite.checked;
221:
222: this.document.server.elements.remember.value
223: =this.document.client.elements.remember.checked;
224:
225: uextkey=this.document.client.elements.uextkey.value;
226: lextkey=this.document.client.elements.lextkey.value;
227: initkeys();
228:
229: this.document.server.elements.upass.value
230: =crypted(this.document.client.elements.upass.value);
231:
232: this.document.server.submit();
233: return false;
234: }
235: </script>
236: ENDSCRIPT
237:
238: if ($fullgraph) {
239: $r->print(
240: '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
241: }
242:
243: $r->print(<<ENDSERVERFORM);
244: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
245: <input type="hidden" name="logtoken" value="$logtoken" />
246: <input type="hidden" name="serverid" value="$lonhost" />
247: <input type="hidden" name="interface" value="$ENV{'form.interface'}" />
248: <input type="hidden" name="uname" value="" />
249: <input type="hidden" name="upass" value="" />
250: <input type="hidden" name="udom" value="" />
251: <input type="hidden" name="imagesuppress" value="" />
252: <input type="hidden" name="appletsuppress" value="" />
253: <input type="hidden" name="embedsuppress" value="" />
254: <input type="hidden" name="fontenhance" value="" />
255: <input type="hidden" name="blackwhite" value="" />
256: <input type="hidden" name="remember" value="" />
257: </form>
258: ENDSERVERFORM
259: if ($fullgraph) { $r->print(<<ENDTOP);
260: <!-- The LON-CAPA Header -->
261: <tr>
262:
263: <!-- Row 1 Columns 2-4 -->
264: <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>
265: </tr>
266:
267: <!-- The gray bar that starts the two table frames -->
268: <tr>
269:
270: <!-- Row 2 Column 1 -->
271: <td width=182 height=27 bgcolor="$sidebg"> </td>
272:
273: <!-- Row 2 Column 2 -->
274: <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
275:
276: <!-- Row 2 Column 3 -->
277: <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
278:
279: <!-- Row 2 Column 4 -->
280: <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
281: </tr>
282: <tr>
283:
284: <!-- A cell that will hold the 'access' and 'about' buttons -->
285: <!-- Row 3 Column 1 -->
286: <td valign="top" height=60 align="center" bgcolor="$sidebg">
287: <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
288: <br />
289: <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
290: </td>
291:
292: <!-- The shaded space between the two main columns -->
293: <!-- Row 3 Column 2 -->
294: <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
295:
296: <!-- The right main column holding the large LON-CAPA logo-->
297: <!-- Rows 3-4 Column 3 -->
298: <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
299: <center>
300: <img src="$logo" alt="" />
301: </center>
302: </td>
303:
304: <!-- Row 3 Column 4 -->
305: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
306: </tr>
307: <tr>
308:
309: <!-- The entry form -->
310: <!-- Row 4 Column 1 -->
311: <td align="center" valign="middle" bgcolor="$sidebg">
312: ENDTOP
313: } else {
314: $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>');
315: }
316: $r->print('<form name="client" onsubmit="return(send())">');
317: unless ($fullgraph) {
318: $r->print(<<ENDACCESSOPTIONS);
319: <h3>Select Accessibility Options</h3>
320: <input type="checkbox" name="imagesuppress" /> Suppress rendering of images<br />
321: <input type="checkbox" name="appletsuppress" /> Suppress Java applets<br />
322: <input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia<br />
323: <input type="checkbox" name="fontenhance" /> Increase font size<br />
324: <input type="checkbox" name="blackwhite" /> Switch to black and white mode<br />
325: <p>If you have accessibility needs that are not addressed by this interface,
326: please
327: contact the system administrator at <tt>$sysadm</tt>.</p><br />
328: <input type="checkbox" name="remember" /> Remember these settings for next login<hr />
329: ENDACCESSOPTIONS
330: } else {
331: $r->print(<<ENDNOOPT);
332: <input type="hidden" name="imagesuppress" value="" />
333: <input type="hidden" name="embedsuppress" value="" />
334: <input type="hidden" name="appletsuppress" value="" />
335: <input type="hidden" name="fontenhance" value="" />
336: <input type="hidden" name="blackwhite" value="" />
337: <input type="hidden" name="remember" value="" />
338: ENDNOOPT
339: }
340: $r->print(<<ENDLOGIN);
341: <input type="hidden" name="lextkey" value="$lextkey">
342: <input type="hidden" name="uextkey" value="$uextkey">
343:
344: <!-- Start the sub-table for text and input alignment -->
345: <table border=0 cellspacing=0 cellpadding=0>
346: <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
347: <tr>
348: <td bgcolor="$mainbg"><br /><font size=-1><b> User Name:</b></font></td>
349: <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
350: </tr>
351: <tr>
352: <td bgcolor="$mainbg"><font size=-1><b> Password:</b></font></td>
353: <td bgcolor="$mainbg"><input type="password" name="upass" size="10" /></td>
354: </tr>
355: <tr>
356: <td bgcolor="$mainbg"><font size=-1><b> Domain:</b></font></td>
357: <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
358: </tr>
359: <tr>
360: <td bgcolor="$mainbg"> <a href="/adm/loginproblems.html">Help</a></td>
361: <td bgcolor="$mainbg" valign="bottom" align="center">
362: <br />
363: <input type="submit" value="Log In" />
364: </td>
365: </tr>
366: </table>
367: <!-- End sub-table -->
368: </form>
369: ENDLOGIN
370: if ($fullgraph) {
371: $r->print(<<ENDDOCUMENT);
372: </td>
373:
374: <!-- Row 4 Column 2 -->
375: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
376:
377: <!-- Row 4 Column 4 -->
378: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
379: </tr>
380: <tr>
381:
382: <!-- Row 5 Column 1 -->
383: <td bgcolor="$sidebg" valign="middle" align="left">
384: <br />
385: <table border=0 cellspacing=0 cellpadding=0>
386: <tr>
387: <td bgcolor="$sidebg" align="left" valign="top">
388: <small><b> Domain: </b></small>
389: </td>
390: <td bgcolor="$sidebg" align="left" valign="top">
391: <small><tt> $domain</tt></small>
392: </td>
393: </tr>
394: <tr>
395: <td bgcolor="$sidebg" align="left" valign="top">
396: <small><b> Server: </b></small>
397: </td>
398: <td bgcolor="$sidebg" align="left" valign="top">
399: <small><tt> $lonhost ($role)</tt></small>
400: </td>
401: </tr>
402: <tr>
403: <td bgcolor="$sidebg" align="left" valign="top">
404: <small><b> Load: </b></small>
405: </td>
406: <td bgcolor="$sidebg" align="left" valign="top">
407: <small><tt> $loadpercent percent</tt></small>
408: </td>
409: </tr>
410: </table>
411: <br />
412: <small>
413: <b> System Administration:</b><br />
414: <tt> $sysadm</tt><br />
415: <b> Server Administration:</b><br />
416: <tt> $servadm<br /> </tt>
417: </small>
418: </td>
419:
420: <!-- Row 5 Column 2 -->
421: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
422:
423: <!-- Row 5 Column 3 -->
424: <td width="100%" valign="bottom" bgcolor="$mainbg">
425: $domainlogo
426: </td>
427:
428: <!-- Row 5 Column 4 -->
429: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
430: </tr>
431: <tr>
432:
433: <!-- Row 6 Column 1 -->
434: <td bgcolor="$sidebg"> </td>
435:
436: <!-- Row 6 Column 2 -->
437: <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
438:
439: <!-- Row 6 Column 3 -->
440: <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
441:
442: <!-- Row 6 Column 4 -->
443: <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
444: </tr>
445: </table>
446:
447: <script>
448: // the if prevents the script error if the browser can't handle this
449: if ( document.client.uname ) { document.client.uname.focus(); }
450: </script>
451:
452: ENDDOCUMENT
453: }
454: $r->print('</body></html>');
455: return OK;
456: }
457:
458: 1;
459: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>