aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/auth.py
diff options
context:
space:
mode:
authorGravatar Paweł Zuzelski <pawelz@pld-linux.org>2010-01-10 02:39:50 +0100
committerGravatar Paweł Zuzelski <pawelz@pld-linux.org>2010-01-10 02:39:50 +0100
commite1806cf413fbafa7dfef273ca4ced37e1918d080 (patch)
treedcbf0767fad00bd02c1b48791184890834988aca /examples/data/scripts/auth.py
parent91e081938617e24dea672949c58b8dbad8d19630 (diff)
authentication_handler implementaion
Authentication handler allows to delegate http authentication to external program. It introduces one new configuration variable: authentication_handler. Note that this commit does not affect uzbl behaviour unless this variable is set. Also updated README documentation, default config and added example authentication script.
Diffstat (limited to 'examples/data/scripts/auth.py')
-rw-r--r--examples/data/scripts/auth.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/examples/data/scripts/auth.py b/examples/data/scripts/auth.py
new file mode 100644
index 0000000..4feb90b
--- /dev/null
+++ b/examples/data/scripts/auth.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+import gtk
+import sys
+
+def responseToDialog(entry, dialog, response):
+ dialog.response(response)
+
+def getText(authInfo, authHost, authRealm):
+ dialog = gtk.MessageDialog(
+ None,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_QUESTION,
+ gtk.BUTTONS_OK_CANCEL,
+ None)
+ dialog.set_markup('%s at %s' % (authRealm, authHost))
+
+ login = gtk.Entry()
+ password = gtk.Entry()
+ password.set_visibility(False)
+
+ login.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
+ password.connect("activate", responseToDialog, dialog, gtk.RESPONSE_OK)
+
+ hbox = gtk.HBox();
+
+ vbox_entries = gtk.VBox();
+ vbox_labels = gtk.VBox();
+
+ vbox_labels.pack_start(gtk.Label("Login:"), False, 5, 5)
+ vbox_labels.pack_end(gtk.Label("Password:"), False, 5, 5)
+
+ vbox_entries.pack_start(login)
+ vbox_entries.pack_end(password)
+
+ dialog.format_secondary_markup("Please enter username and password:")
+ hbox.pack_start(vbox_labels, True, True, 0)
+ hbox.pack_end(vbox_entries, True, True, 0)
+
+ dialog.vbox.pack_start(hbox)
+ dialog.show_all()
+ rv = dialog.run()
+
+ output = login.get_text() + "\n" + password.get_text()
+ dialog.destroy()
+ return rv, output
+
+if __name__ == '__main__':
+ rv, output = getText(sys.argv[8], sys.argv[9], sys.argv[10])
+ if (rv == gtk.RESPONSE_OK):
+ print output;
+ else:
+ exit(1)