How to log out user from web site using BASIC authentication?

后端 未结 22 1432
感情败类
感情败类 2020-11-22 04:00

Is it possible to log out user from a web site if he is using basic authentication?

Killing session is not enough, since, once user is authenticated, each request co

22条回答
  •  盖世英雄少女心
    2020-11-22 04:31

    Just for the record, there is a new HTTP Response Header called Clear-Site-Data. If your server reply includes a Clear-Site-Data: "cookies" header, then the authentication credentials (not only cookies) should be removed. I tested it on Chrome 77 but this warning shows on the console:

    Clear-Site-Data header on 'https://localhost:9443/clear': Cleared data types:
    "cookies". Clearing channel IDs and HTTP authentication cache is currently not
    supported, as it breaks active network connections.
    

    And the auth credentials aren't removed, so this doesn't works (for now) to implement basic auth logouts, but maybe in the future will. Didn't test on other browsers.

    References:

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data

    https://www.w3.org/TR/clear-site-data/

    https://github.com/w3c/webappsec-clear-site-data

    https://caniuse.com/#feat=mdn-http_headers_clear-site-data_cookies

提交回复
热议问题