basicauth-go icon indicating copy to clipboard operation
basicauth-go copied to clipboard

logout

Open mindscratch opened this issue 7 years ago • 2 comments

How might I logout a user?

mindscratch avatar Oct 31 '17 18:10 mindscratch

https://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authentication

Basic Authentication wasn't designed to manage logging out. You can do it, but not completely automatically.

What you have to do is have the user click a logout link, and send a ‘401 Unauthorized’ in response, using the same realm and at the same URL folder level as the normal 401 you send requesting a login.

to be honest if you want logout you probably should add session/cookie based auth instead.

vektah avatar Oct 31 '17 21:10 vektah

That's interesting, I'll give it a shot. I was wondering, because it seems browser might cache something? When I access the site with basic auth, the first time I enter username/password, then it no longer prompts until I clear browser cache or use a "private" browser window.

mindscratch avatar Nov 01 '17 01:11 mindscratch