From e1806cf413fbafa7dfef273ca4ced37e1918d080 Mon Sep 17 00:00:00 2001 From: Paweł Zuzelski Date: Sun, 10 Jan 2010 02:39:50 +0100 Subject: 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. --- examples/data/scripts/auth.py | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/data/scripts/auth.py (limited to 'examples/data/scripts/auth.py') 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) -- cgit v1.2.3