Is there a browser equivalent to IE's ClearAuthenticationCache?

后端 未结 7 1271
慢半拍i
慢半拍i 2020-11-30 00:58

I have a few internal .net web application here that require users to \"log out\" of them. I know this may seem moot on an Intranet application, but nonetheless it is there.

7条回答
  •  爱一瞬间的悲伤
    2020-11-30 01:08

    Mozilla implemented the crypto object, available via the DOM window object, which has the logout function (Firefox 1.5 upward) to clear the SSL session state at the browser level so that "the next private operation on any token will require the user password again" (see this).

    The crypto object seems to be an implementation of the Web Crypto API, and according to this document, the DOMCrypt API will add even more functions.

    As stated above Microsoft IE (6 upward) has: document.execCommand("ClearAuthenticationCache", "false")

    I have found no way of clearing the SLL cache in Chrome (see this and this bug reports).

    In case the browser does not offer any API to do this, I think the better we can do is to instruct the user to close the browser.

    Here's what I do:

    var agt=navigator.userAgent.toLowerCase();
    if (agt.indexOf("msie") !== -1) {
        document.execCommand("ClearAuthenticationCache","false");
    }
    //window.crypto is defined in Chrome, but it has no logout function
    else if (window.crypto && typeof window.crypto.logout === "function"){
        window.crypto.logout();
    }
    else{
        window.location = "/page/to/instruct/the/user/to/close/the/browser";
    }
    

提交回复
热议问题