Changes between Version 26 and Version 27 of TrueHttpLogoutPatch
- Timestamp:
- Apr 10, 2017, 11:19:53 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TrueHttpLogoutPatch
v26 v27 5 5 == Description 6 6 7 This patch allows you to logout from Basic/Digest Auth without closing the browser.7 This script allows you to logout from Basic/Digest auth without closing the browser. 8 8 9 9 * Apache [http://httpd.apache.org/docs/1.3/howto/auth.html#basicfaq claims that it is not possible]. 10 * Nano Docume t [http://www.nanodocumet.com/?p=6 gives a solution] that simply works.10 * Nano Document [http://www.nanodocumet.com/?p=6 gives a solution] that simply works. 11 11 12 12 The concept is explained on [http://www.berenddeboer.net/rest/authentication.html Berend de Boer page]. 13 13 14 This patch works for `tracd` standalone. There's no need of Apache or any other server. 15 This patch should work on all platform, although I've only tested version 0.9.6 on Windows XP. 14 == Bugs/Feature Requests 16 15 17 Notes: 18 * Tested successfully with Firefox and Internet Explorer 6. 19 * It works fine with Camino. 20 * It may not work with Safari and Konqueror. 16 Existing bugs and feature requests for TrueHttpLogoutPatch are 17 [report:9?COMPONENT=TrueHttpLogoutPatch here]. 21 18 22 == Usage 19 If you have any issues, create a 20 [/newticket?component=TrueHttpLogoutPatch new ticket]. 23 21 24 * file `Share\trac\htdocs\js\trac.js`, append at the end of file: 25 {{{ 26 function clearAuthenticationCache(page) { 27 // Default to a non-existing page (give error 500). 28 // An empty page is better, here. 29 if (!page) page = '.force_logout'; 30 try{ 31 var agt=navigator.userAgent.toLowerCase(); 32 if (agt.indexOf("msie") != -1) { 33 // IE clear HTTP Authentication 34 document.execCommand("ClearAuthenticationCache"); 35 } 36 else { 37 // Let's create an xmlhttp object 38 var xmlhttp = createXMLObject(); 39 // Let's prepare invalid credentials 40 xmlhttp.open("GET", page, true, "logout", "logout"); 41 // Let's send the request to the server 42 xmlhttp.send(""); 43 // Let's abort the request 44 xmlhttp.abort(); 45 } 46 } catch(e) { 47 // There was an error 48 return; 49 } 50 } 51 52 function createXMLObject() { 53 try { 54 if (window.XMLHttpRequest) { 55 xmlhttp = new XMLHttpRequest(); 56 } 57 // code for IE 58 else if (window.ActiveXObject) { 59 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 60 } 61 } catch (e) { 62 xmlhttp=false 63 } 64 return xmlhttp; 65 } 66 }}} 22 [[TicketQuery(component=TrueHttpLogoutPatch&group=type,format=progress)]] 67 23 68 * file `Lib\site-packages\trac\web\auth.py`, locate method `get_navigation_items`, and change: 69 {{{ 70 yield ('metanav', 'logout', 71 Markup('<a href="%s">Logout</a>' 72 % escape(self.env.href.logout()))) 73 }}} 74 to: 75 {{{ 76 yield ('metanav', 'logout', 77 Markup('<a href="%s" onclick="clearAuthenticationCache(\'%s\');">Logout</a>' 78 % ((escape(self.env.href.logout()),) *2) )) 79 }}} 24 == Download 80 25 81 * Now that's ok to start `tracd` and test logout feature.26 Download the zipped source from [export:truehttplogoutpatch here]. 82 27 83 (Patches for other versions below) 28 == Source 29 30 You can check out TrueHttpLogoutPatch from [/svn/truehttplogoutpatch here] using Subversion, or [source:truehttplogoutpatch browse the source] with Trac. 31 32 == Installation 33 34 * Add `site.html` to the [TracEnvironment#DirectoryStructure project] or [TracIni#inherit-templates_dir-option shared] `templates` directory. 35 * Add `site.js` to the project or [TracIni#inherit-htdocs_dir-option shared] `htdocs` directory. 84 36 85 37 == Recent Changes