2 include("/scripting/common.js");
4 /* this script is called on every web request. If it produces any
5 output at all then that output is returned and the requested page
6 is not given or processed.
10 check if a uri is one of the 'always allowed' pages, even when not logged in
11 This allows the login page to use the same style sheets and images
13 function always_allowed(uri) {
14 var str = string_init();
16 /* allow jsonrpc-based applications to do their own authentication */
17 var s = str.split('/', uri);
18 if (s[0] == "" && s[1] == 'index.html') {
22 var s = str.split('.', uri);
27 var ext = s[s.length-1];
28 var allowed = new Array("ico", "gif", "png","css", "js");
30 if (allowed[i] == ext) {
38 if (server['SERVER_PROTOCOL'] == "http" &&
39 server['TLS_SUPPORT'] == "True") {
40 write("redirect to https");
41 redirect("https://" + headers['HOST'] + request['REQUEST_URI']);
42 } else if (always_allowed(request['REQUEST_URI']) != true &&
43 session['AUTHENTICATED'] == undefined) {
44 /* present the login page */
45 include("/login.esp");