mirror of
https://github.com/andrey271192/kaskad.git
synced 2026-09-21 13:51:57 +00:00
fix(webui): logout via XHR wrong Basic creds (Chrome-safe)
fetch()+manual Authorization is ignored when browser has cached HTTP auth.
Use XMLHttpRequest.open(user,password) with random bogus pair, then
location.replace('/') so login prompts again. Add Cache-Control on 401.
Header buttons: type=button, @click.prevent on logout.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
14
webui/app.py
14
webui/app.py
@@ -594,10 +594,18 @@ def api_change_password():
|
||||
|
||||
@app.route("/api/logout")
|
||||
def api_logout():
|
||||
"""Возвращаем 401 с новым realm — браузер сбрасывает кеш Basic Auth."""
|
||||
"""401 + смена realm — подсказка браузеру забыть предыдущий Basic Auth.
|
||||
|
||||
Клиент должен дергать этот URL через XMLHttpRequest.open(..., user, password)
|
||||
с заведомо неверной парой; иначе многие браузеры подставят сохранённые креды."""
|
||||
return Response(
|
||||
"logged out", 401,
|
||||
{"WWW-Authenticate": f'Basic realm="kaskad-logout-{os.urandom(4).hex()}"'},
|
||||
"logged out\n",
|
||||
401,
|
||||
{
|
||||
"WWW-Authenticate": f'Basic realm="kaskad-logout-{os.urandom(4).hex()}"',
|
||||
"Cache-Control": "no-store, no-cache, must-revalidate",
|
||||
"Pragma": "no-cache",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user