summaryrefslogtreecommitdiff
path: root/swat/scripting/preauth.esp
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-09-07 03:08:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:05:21 -0500
commitf8573766bc17af0afacc5d44d3c3d8234b426dbf (patch)
tree55dfe87448d6332ff48ba6e74fd3226fdd7422f6 /swat/scripting/preauth.esp
parent8f3ab786f03e1bb5bf73fe9d7264b1b0bbb90a75 (diff)
downloadsamba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.tar.gz
samba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.tar.bz2
samba-f8573766bc17af0afacc5d44d3c3d8234b426dbf.zip
r24985: Start to revert us back to the old-style SWAT, while trying not to
loose some of the fixes in the meantime. Andrew Bartlett (This used to be commit 13acff5ed259e7b5859fd2324ea7740b8f9e5fd7)
Diffstat (limited to 'swat/scripting/preauth.esp')
-rw-r--r--swat/scripting/preauth.esp48
1 files changed, 48 insertions, 0 deletions
diff --git a/swat/scripting/preauth.esp b/swat/scripting/preauth.esp
new file mode 100644
index 0000000000..e6d04faf8d
--- /dev/null
+++ b/swat/scripting/preauth.esp
@@ -0,0 +1,48 @@
+<%
+include("/scripting/common.js");
+
+/* 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.
+*/
+
+/*
+ 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 jsonrpc-based applications to do their own authentication */
+ var s = str.split('/', uri);
+ if (s[0] == "" && s[1] == 'index.html') {
+ 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;
+}
+
+
+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");
+}
+
+%>