最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to remove 'Authorization: Basic username:password' header from browser - Stack Overflow

programmeradmin9浏览0评论

I've been trying to make use of the native login prompt that is available in browsers:

and have been following Steven Sanderson's blog post.

As mentioned in the blog, once a user enters their login details once the browser then sends the header Authorization: Basic username:password in all future requests to the login URL. This means that if a user logs out, but doesn't close the browser window, the next time they visit the login page, they are logged in automatically when visiting the login page. Effectively the browser stores the authentication details until the browser closes down - leaving your account open to unauthorised access.

Is there a way to make the browser forget the authorization information so that the user cannot log in again wihtout re-entering their details?

I've been trying to make use of the native login prompt that is available in browsers:

and have been following Steven Sanderson's blog post.

As mentioned in the blog, once a user enters their login details once the browser then sends the header Authorization: Basic username:password in all future requests to the login URL. This means that if a user logs out, but doesn't close the browser window, the next time they visit the login page, they are logged in automatically when visiting the login page. Effectively the browser stores the authentication details until the browser closes down - leaving your account open to unauthorised access.

Is there a way to make the browser forget the authorization information so that the user cannot log in again wihtout re-entering their details?

Share Improve this question asked Oct 16, 2011 at 19:02 Mr. FlibbleMr. Flibble 27k23 gold badges71 silver badges100 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 16

As it written in wikipedia:

Existing browsers retain authentication information until the tab or browser is closed or the user clears the history. [1] HTTP does not provide a method for a server to direct clients to discard these cached credentials. This means that there is no effective way for a server to "log out" the user without closing the browser. This is a significant defect that requires browser manufacturers to support a 'logout' user interface element (mentioned in RFC 1945, but not implemented by most browsers) or API available to JavaScript, further extensions to HTTP, or use of existing alternative techniques such as retrieving the page over SSL/TLS with an unguessable string in the URL.

Seems it is no way in general.

发布评论

评论列表(0)

  1. 暂无评论