Changes between Version 1 and Version 2 of TrueHttpLogoutPatch


Ignore:
Timestamp:
Aug 17, 2006, 8:53:53 PM (18 years ago)
Author:
Florent
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TrueHttpLogoutPatch

    v1 v2  
    33== Description ==
    44
    5 This patch will allow to logout from Basic Auth.
     5This patch allows to logout from Basic/Digest Auth without closing the browser.
    66
    7 On one hand Apache claims that it is not possible.
    8 On other hand, i've found a solution that work with most recent browsers.
     7On one hand Apache [http://httpd.apache.org/docs/1.3/howto/auth.html#basicfaq claims that it is not possible].[[BR]]
     8On other hand, Nano Documet [http://nanodocumet.homedns.org/rest/ give a solution] that works with most recent browsers.
    99
     10This patch works for `tracd` standalone. There's no need of Apache or any other server.
    1011
    11 == Bugs/Feature Requests ==
     12I am lazy tonight, so i give you only the file changes.[[BR]]
     13This patch should work on all platform, although I've tested Windows only.
    1214
    13 Existing bugs and feature requests for TrueHttpLogoutPatch are
    14 [report:9?COMPONENT=TrueHttpLogoutPatch here].
     15== Usage ==
    1516
    16 If you have any issues, create a
    17 [http://trac-hacks.org/newticket?component=TrueHttpLogoutPatch&owner=flox new ticket].
     17 * first remove buggy AuthFormPlugin  ;-)
    1818
    19 == Download ==
     19 * file `Share\trac\htdocs\js\trac.js`, append at the end of file:
     20    {{{
     21    function clearAuthenticationCache() {
     22      try{
     23        var agt=navigator.userAgent.toLowerCase();
     24        if (agt.indexOf("msie") != -1) {
     25          // IE clear HTTP Authentication
     26          document.execCommand("ClearAuthenticationCache");
     27        }
     28        else {
     29          // Let's create an xmlhttp object
     30          var xmlhttp = createXMLObject();
     31          // Let's get the force page to logout for mozilla
     32          xmlhttp.open("GET",".force_logout_offer_login_mozilla",true,"logout","logout");
     33          // Let's send the request to the server
     34          xmlhttp.send("");
     35          // Let's abort the request
     36          xmlhttp.abort();
     37        }
     38      // Let's redirect the user to the main webpage
     39      //  window.location = "/rest/";
     40      } catch(e) {
     41      // There was an error
     42      alert("there was an error");
     43      }
     44    }
     45   
     46    function createXMLObject() {
     47      try {
     48        if (window.XMLHttpRequest) {
     49          xmlhttp = new XMLHttpRequest();
     50        }
     51        // code for IE
     52        else if (window.ActiveXObject) {
     53          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     54        }
     55      } catch (e) {
     56        xmlhttp=false
     57      }
     58      return xmlhttp;
     59    }
     60    }}}
    2061
    21 Download the zipped source from [download:truehttplogoutpatch here].
     62 * file `Lib\site-packages\trac\web\auth.py`, locate method `get_navigation_items`, and change:
     63    {{{
     64            yield ('metanav', 'logout',
     65                   Markup('<a href="%s">Logout</a>'
     66                          % escape(self.env.href.logout())))
     67    }}}
     68   to:
     69    {{{
     70            yield ('metanav', 'logout',
     71                   Markup('<a href="%s" onclick="clearAuthenticationCache();return true;">Logout</a>'
     72                          % escape(self.env.href.logout())))
     73    }}}
    2274
    23 == Source ==
    24 
    25 You can check out TrueHttpLogoutPatch from [http://trac-hacks.org/svn/truehttplogoutpatch here] using Subversion, or [source:truehttplogoutpatch browse the source] with Trac.
    26 
    27 == Example ==
    28 
    29 Stay tuned.
     75  * Now that's ok to start `tracd` and test logout feature.
    3076
    3177== Recent Changes ==