summaryrefslogtreecommitdiff
path: root/webapps/scripting/preauth.esp
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2006-12-31 20:05:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:30:39 -0500
commit43470b5ec3d451aa75acf2cda40cf2dcc019efab (patch)
treeb5050af45bd3c56a33332b6cbb0a5e0ff69ab6b3 /webapps/scripting/preauth.esp
parent4024697a0b7b97acdc5c411ab9fe8c894c66752e (diff)
downloadsamba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.tar.gz
samba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.tar.bz2
samba-43470b5ec3d451aa75acf2cda40cf2dcc019efab.zip
r20444: WEB Application framework / SWAT.
We're now at the stage where the web application framework should build and install automatically. Derrell (This used to be commit 0201baef46c1701007e0a4cdd95edee287939318)
Diffstat (limited to 'webapps/scripting/preauth.esp')
-rw-r--r--webapps/scripting/preauth.esp49
1 files changed, 49 insertions, 0 deletions
diff --git a/webapps/scripting/preauth.esp b/webapps/scripting/preauth.esp
new file mode 100644
index 0000000000..84534cacef
--- /dev/null
+++ b/webapps/scripting/preauth.esp
@@ -0,0 +1,49 @@
+<%
+include("/scripting/common.js");
+
+/*
+ check if a uri is one of the 'always allowed' pages, even when not logged in
+ This allows the login page to use the same style sheets and images
+*/
+function always_allowed(uri) {
+ var str = string_init();
+
+ /* allow the primary web application to do its own authentication */
+ var s = str.split('/', uri);
+ if (s[0] == "" && (s.length == 1 || /* no path provided */
+ s[1] == 'index.html' ||
+ s[1] == "script" ||
+ s[1] == "resource")) {
+ return true;
+ }
+
+ var s = str.split('.', uri);
+ if (s.length < 2) {
+ return false;
+ }
+
+ var ext = s[s.length-1];
+ var allowed = new Array("ico", "gif", "png","css", "js");
+ for (i in allowed) {
+ if (allowed[i] == ext) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/* this script is called on every web request. If it produces any
+ output at all then that output is returned and the requested page
+ is not given or processed.
+*/
+if (server['SERVER_PROTOCOL'] == "http" &&
+ server['TLS_SUPPORT'] == "True") {
+ write("redirect to https");
+ redirect("https://" + headers['HOST'] + request['REQUEST_URI']);
+} else if (always_allowed(request['REQUEST_URI']) != true &&
+ session['AUTHENTICATED'] == undefined) {
+ /* present the login page */
+ include("/login.esp");
+}
+%>