Log out the current Hub session after password changes
This commit is contained in:
1 parent
79b5884a97
commit
e0317344b4
4 files changed
+360
-24
No files matched your search
@@ -0,0 +1,128 @@
|
|||||||
|
"""Password changes end the current Hub session; only loopback and temporary state."""
|
||||||
|
import http.client
|
||||||
|
import importlib.util
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import threading
|
||||||
|
import unittest
|
||||||
|
import urllib.parse
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE = Path(os.environ.get("OWRT_PASSWORD_LOGOUT_HUB_SOURCE", Path(__file__).resolve().parents[1] / "vps/owrt-remote-hub.py"))
|
||||||
|
STATE = tempfile.TemporaryDirectory(prefix="owrt-password-logout-tests-")
|
||||||
|
spec = importlib.util.spec_from_file_location("password_logout_hub", SOURCE)
|
||||||
|
hub = importlib.util.module_from_spec(spec)
|
||||||
|
sys.modules[spec.name] = hub
|
||||||
|
with mock.patch.dict(os.environ, {"OWRT_REMOTE_STATE_DIR": STATE.name}):
|
||||||
|
spec.loader.exec_module(hub)
|
||||||
|
|
||||||
|
|
||||||
|
class QuietHandler(hub.Handler):
|
||||||
|
def log_message(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordLogoutTests(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
hub.save_auth_state({"username": "test-owner", "password": hub.password_digest("old-password")})
|
||||||
|
hub.save_sessions([])
|
||||||
|
hub.atomic_write_text(hub.SESSION_TOKEN_FILE, "legacy-session\n", mode=0o600)
|
||||||
|
self.token, _ = hub.make_hub_session("test-owner", "127.0.0.1", "test-browser")
|
||||||
|
self.server = hub.HubHTTPServer(("127.0.0.1", 0), QuietHandler)
|
||||||
|
self.server.app = hub.App(Path(STATE.name) / "hub.db", "legacy-session", "test-agent", "")
|
||||||
|
self.server.is_tls = False
|
||||||
|
self.push_patch = mock.patch.object(hub, "queue_web_push_payload")
|
||||||
|
self.push_patch.start()
|
||||||
|
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
||||||
|
self.thread.start()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.server.shutdown()
|
||||||
|
self.server.server_close()
|
||||||
|
self.thread.join(timeout=5)
|
||||||
|
self.push_patch.stop()
|
||||||
|
|
||||||
|
def request(self, path, payload=None, token=None, secure=False):
|
||||||
|
headers = {"Cookie": f"{hub.SESSION_COOKIE}={self.token if token is None else token}"}
|
||||||
|
if secure:
|
||||||
|
headers["X-Forwarded-Proto"] = "https"
|
||||||
|
body = None
|
||||||
|
if payload is not None:
|
||||||
|
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||||
|
body = urllib.parse.urlencode(payload)
|
||||||
|
conn = http.client.HTTPConnection("127.0.0.1", self.server.server_port, timeout=5)
|
||||||
|
try:
|
||||||
|
conn.request("POST" if payload is not None else "GET", path, body=body, headers=headers)
|
||||||
|
res = conn.getresponse()
|
||||||
|
return res.status, dict(res.getheaders()), res.read()
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
def change_payload(self, **patch):
|
||||||
|
return {"username": "test-owner", "current_password": "old-password", "password": "new-password", "password_confirm": "new-password", **patch}
|
||||||
|
|
||||||
|
def test_success_clears_cookie_revokes_current_session_and_accepts_new_password(self):
|
||||||
|
status, headers, body = self.request("/api/auth", self.change_payload(), secure=True)
|
||||||
|
self.assertEqual(status, 200)
|
||||||
|
self.assertIn("Доступ к Hub обновлен", body.decode())
|
||||||
|
self.assertEqual(headers["X-Hub-Reauth"], "1")
|
||||||
|
self.assertIn("Max-Age=0", headers["Set-Cookie"])
|
||||||
|
self.assertIn("HttpOnly", headers["Set-Cookie"])
|
||||||
|
self.assertIn("Secure", headers["Set-Cookie"])
|
||||||
|
self.assertIsNone(hub.verify_hub_session(self.token, touch=False))
|
||||||
|
self.assertEqual(self.request("/api/sessions")[0], 401)
|
||||||
|
self.assertFalse(hub.verify_login("test-owner", "old-password"))
|
||||||
|
self.assertTrue(hub.verify_login("test-owner", "new-password"))
|
||||||
|
code, challenge = hub.captcha_challenge()
|
||||||
|
status, headers, _ = self.request("/login", {
|
||||||
|
"username": "test-owner", "password": "new-password",
|
||||||
|
"captcha_token": challenge, "captcha_answer": code,
|
||||||
|
}, token="")
|
||||||
|
self.assertEqual(status, 302)
|
||||||
|
self.assertEqual(headers["Location"], "/")
|
||||||
|
self.assertNotIn("Max-Age=0", headers["Set-Cookie"])
|
||||||
|
|
||||||
|
def test_rejected_password_changes_keep_password_and_session(self):
|
||||||
|
for patch, expected in (({"current_password": "wrong"}, 403), ({"password_confirm": "different"}, 400), ({"password": "x", "password_confirm": "x"}, 400)):
|
||||||
|
with self.subTest(patch=patch):
|
||||||
|
status, headers, _ = self.request("/api/auth", self.change_payload(**patch))
|
||||||
|
self.assertEqual(status, expected)
|
||||||
|
self.assertNotIn("X-Hub-Reauth", headers)
|
||||||
|
self.assertNotIn("Set-Cookie", headers)
|
||||||
|
self.assertTrue(hub.verify_login("test-owner", "old-password"))
|
||||||
|
self.assertIsNotNone(hub.verify_hub_session(self.token, touch=False))
|
||||||
|
self.assertEqual(self.request("/api/sessions")[0], 200)
|
||||||
|
|
||||||
|
def test_captcha_settings_without_new_password_keep_current_session(self):
|
||||||
|
status, headers, _ = self.request("/api/auth", {"current_password": "old-password", "captcha_mode": "digits", "password": ""})
|
||||||
|
self.assertEqual(status, 200)
|
||||||
|
self.assertNotIn("X-Hub-Reauth", headers)
|
||||||
|
self.assertNotIn("Set-Cookie", headers)
|
||||||
|
self.assertIsNotNone(hub.verify_hub_session(self.token, touch=False))
|
||||||
|
self.assertEqual(self.request("/api/sessions")[0], 200)
|
||||||
|
|
||||||
|
def test_legacy_cookie_is_invalid_after_password_change_and_restart(self):
|
||||||
|
status, headers, _ = self.request("/api/auth", self.change_payload(), token="legacy-session")
|
||||||
|
self.assertEqual(status, 200)
|
||||||
|
self.assertEqual(headers["X-Hub-Reauth"], "1")
|
||||||
|
self.assertNotEqual(self.server.app.session_token, "legacy-session")
|
||||||
|
self.assertEqual(hub.session_token(), self.server.app.session_token)
|
||||||
|
self.assertEqual(self.request("/api/sessions", token="legacy-session")[0], 401)
|
||||||
|
# A new process reads the rotated token, so the old cookie stays invalid.
|
||||||
|
self.server.app.session_token = hub.session_token()
|
||||||
|
self.assertEqual(self.request("/api/sessions", token="legacy-session")[0], 401)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) == 3 and sys.argv[1] == "--export-js":
|
||||||
|
page = hub.dashboard_html([], "test-owner", auth_bootstrap={"is_owner": True})
|
||||||
|
output = Path(sys.argv[2])
|
||||||
|
output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output.write_text("\n".join(re.findall(r"<script>(.*?)</script>", page, re.S)), encoding="utf-8")
|
||||||
|
print(f"JavaScript exported to {output}")
|
||||||
|
else:
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// node tests/test_password_logout_ui.cjs <exported-dashboard.js>
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const vm = require('node:vm');
|
||||||
|
const source = fs.readFileSync(process.argv[2], 'utf8').replace(/\r\n/g, '\n');
|
||||||
|
const start = source.indexOf("authForm.addEventListener('submit', async (ev) => {");
|
||||||
|
const end = source.indexOf('\nif (delegatedUserReset)', start);
|
||||||
|
assert(start >= 0 && end > start);
|
||||||
|
|
||||||
|
function fixture({password = 'new-password', ok = true, reauth = '1'} = {}) {
|
||||||
|
let submit;
|
||||||
|
const redirects = [], remembered = [], messages = [];
|
||||||
|
let reloads = 0;
|
||||||
|
const form = {
|
||||||
|
password: {value: password}, password_confirm: {value: password}, current_password: {value: 'old-password'},
|
||||||
|
addEventListener(type, fn) { submit = fn; },
|
||||||
|
};
|
||||||
|
const context = {
|
||||||
|
authForm: form, authUsernameDraftDirty: true, authCaptchaDraftDirty: true,
|
||||||
|
window: {location: {replace(url) { redirects.push(url); }}},
|
||||||
|
FormData: class { constructor() { this.password = form.password.value; } *[Symbol.iterator]() { yield ['password', this.password]; } },
|
||||||
|
URLSearchParams,
|
||||||
|
setAuthMessage(...args) { messages.push(args); },
|
||||||
|
setOwnerPasswordRememberEnabled(...args) { remembered.push(args); },
|
||||||
|
ownerPasswordRememberEnabled() { return true; },
|
||||||
|
restoreOwnerPasswordInput() {},
|
||||||
|
async loadAuthMeta() { reloads++; },
|
||||||
|
async fetch(url) {
|
||||||
|
assert.equal(url, '/api/auth');
|
||||||
|
return {ok, headers: {get() { return reauth; }}, async text() { return ok ? 'Saved' : 'Rejected'; }};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
vm.createContext(context);
|
||||||
|
vm.runInContext(source.slice(start, end), context);
|
||||||
|
return {form, redirects, remembered, messages, reloads: () => reloads,
|
||||||
|
submit: () => submit({currentTarget: form, preventDefault() {}, stopImmediatePropagation() {}})};
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const changed = fixture();
|
||||||
|
await changed.submit();
|
||||||
|
assert.deepEqual(changed.redirects, ['/login']);
|
||||||
|
assert.deepEqual(changed.remembered, [[false]]);
|
||||||
|
assert.equal(changed.form.password.value, '');
|
||||||
|
assert.equal(changed.form.password_confirm.value, '');
|
||||||
|
assert.equal(changed.reloads(), 0, 'do not reload protected APIs after logout');
|
||||||
|
|
||||||
|
const fallback = fixture({reauth: null});
|
||||||
|
await fallback.submit();
|
||||||
|
assert.deepEqual(fallback.redirects, ['/login'], 'password POST also redirects when a proxy strips the reauth header');
|
||||||
|
|
||||||
|
const rejected = fixture({ok: false});
|
||||||
|
await rejected.submit();
|
||||||
|
assert.deepEqual(rejected.redirects, []);
|
||||||
|
assert.deepEqual(rejected.remembered, []);
|
||||||
|
assert.equal(rejected.form.password.value, 'new-password');
|
||||||
|
assert.equal(rejected.messages.at(-1)[1], true);
|
||||||
|
|
||||||
|
const settings = fixture({password: '', reauth: null});
|
||||||
|
await settings.submit();
|
||||||
|
assert.deepEqual(settings.redirects, []);
|
||||||
|
assert.equal(settings.reloads(), 1);
|
||||||
|
console.log('PASSWORD_LOGOUT_UI_OK: success redirects immediately, rejection and settings preserve the page');
|
||||||
|
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$Vps,
|
||||||
|
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install',
|
||||||
|
[switch]$PrepareOnly
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||||
|
$UploadName = 'owrt-password-logout-' + [guid]::NewGuid().ToString('N')
|
||||||
|
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
|
||||||
|
$Utf8 = [System.Text.UTF8Encoding]::new($false)
|
||||||
|
|
||||||
|
$RemoteScript = @'
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
stage=/tmp/__UPLOAD_NAME__
|
||||||
|
target=/opt/owrt-remote/owrt-remote-hub.py
|
||||||
|
backup=/opt/owrt-remote/owrt-remote-hub.py.bak-before-password-logout-v114
|
||||||
|
candidate=$target.new-__UPLOAD_NAME__
|
||||||
|
changed=0
|
||||||
|
|
||||||
|
show_failure() {
|
||||||
|
echo '--- owrt-remote status ---' >&2
|
||||||
|
systemctl --no-pager -l status owrt-remote >&2 || true
|
||||||
|
echo '--- owrt-remote journal ---' >&2
|
||||||
|
journalctl -u owrt-remote -n 80 --no-pager -l >&2 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
code=$?
|
||||||
|
trap - EXIT
|
||||||
|
if [ "$code" -ne 0 ]; then
|
||||||
|
echo "Remote step failed with rc=$code" >&2
|
||||||
|
show_failure
|
||||||
|
fi
|
||||||
|
if [ "$code" -ne 0 ] && [ "$changed" = 1 ] && [ -s "$stage/previous.py" ]; then
|
||||||
|
echo 'Restoring the previous Hub file...' >&2
|
||||||
|
cp -p "$stage/previous.py" "$candidate"
|
||||||
|
mv -f "$candidate" "$target"
|
||||||
|
systemctl restart owrt-remote || true
|
||||||
|
fi
|
||||||
|
rm -f "$candidate"
|
||||||
|
rm -rf "$stage"
|
||||||
|
exit "$code"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
test -s "$target"
|
||||||
|
python_bin=/opt/owrt-remote/venv/bin/python
|
||||||
|
[ -x "$python_bin" ] || python_bin=python3
|
||||||
|
|
||||||
|
if [ '__ACTION__' = Install ]; then
|
||||||
|
test -s "$stage/hub.py"
|
||||||
|
echo 'Validating candidate...'
|
||||||
|
"$python_bin" -m py_compile "$stage/hub.py"
|
||||||
|
"$python_bin" - "$stage/hub.py" <<'PY'
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
source = Path(sys.argv[1]).read_text(encoding='utf-8')
|
||||||
|
required = (
|
||||||
|
"revoke_hub_session(token=self.current_session_token())",
|
||||||
|
"X-Hub-Reauth",
|
||||||
|
"window.location.replace('/login');",
|
||||||
|
"setOwnerPasswordRememberEnabled(false);",
|
||||||
|
)
|
||||||
|
missing = [marker for marker in required if marker not in source]
|
||||||
|
if missing:
|
||||||
|
for marker in missing:
|
||||||
|
print('Missing marker:', repr(marker), file=sys.stderr)
|
||||||
|
raise SystemExit(1)
|
||||||
|
print('Candidate validation OK')
|
||||||
|
PY
|
||||||
|
if [ ! -e "$backup" ]; then
|
||||||
|
cp -p "$target" "$backup"
|
||||||
|
fi
|
||||||
|
source_file="$stage/hub.py"
|
||||||
|
else
|
||||||
|
test -s "$backup"
|
||||||
|
"$python_bin" -m py_compile "$backup"
|
||||||
|
source_file="$backup"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -p "$target" "$stage/previous.py"
|
||||||
|
cp "$source_file" "$candidate"
|
||||||
|
chmod 0755 "$candidate"
|
||||||
|
changed=1
|
||||||
|
mv -f "$candidate" "$target"
|
||||||
|
echo 'Restarting owrt-remote...'
|
||||||
|
if ! systemctl restart owrt-remote; then
|
||||||
|
show_failure
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
healthy=0
|
||||||
|
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
||||||
|
if systemctl is-active --quiet owrt-remote && curl -fsS --max-time 5 http://127.0.0.1:8088/health; then
|
||||||
|
healthy=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
if [ "$healthy" -ne 1 ]; then
|
||||||
|
echo 'Health check did not become ready.' >&2
|
||||||
|
show_failure
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cmp "$source_file" "$target"
|
||||||
|
printf '\nBackup: %s\nPASSWORD_LOGOUT_V114_%s_OK\n' "$backup" '__ACTION__'
|
||||||
|
'@
|
||||||
|
|
||||||
|
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
|
||||||
|
|
||||||
|
try {
|
||||||
|
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
|
||||||
|
[System.IO.File]::WriteAllText(
|
||||||
|
(Join-Path $StageRoot 'run.sh'),
|
||||||
|
$RemoteScript.Replace("`r`n", "`n") + "`n",
|
||||||
|
$Utf8
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Action -eq 'Install') {
|
||||||
|
$Content = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'vps\owrt-remote-hub.py')).Replace("`r`n", "`n")
|
||||||
|
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'hub.py'), $Content, $Utf8)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($PrepareOnly) {
|
||||||
|
Write-Host "Prepared only: $StageRoot"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
& scp -O -r -- $StageRoot "${Vps}:/tmp/"
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. VPS was not changed.' }
|
||||||
|
& ssh -T -o ConnectTimeout=10 $Vps "sh /tmp/$UploadName/run.sh"
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
|
||||||
|
Write-Host "Password logout fix $Action finished successfully."
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (-not $PrepareOnly) {
|
||||||
|
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
|
||||||
|
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
|
||||||
|
if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) {
|
||||||
|
throw 'Unsafe staging cleanup path.'
|
||||||
|
}
|
||||||
|
if (Test-Path -LiteralPath $Resolved) {
|
||||||
|
Remove-Item -LiteralPath $Resolved -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
-24
@@ -11199,9 +11199,17 @@ authForm.addEventListener('submit', async (ev) => {{
|
|||||||
const form = ev.currentTarget;
|
const form = ev.currentTarget;
|
||||||
setAuthMessage('');
|
setAuthMessage('');
|
||||||
const body = new URLSearchParams(new FormData(form));
|
const body = new URLSearchParams(new FormData(form));
|
||||||
|
const passwordChanged = !!body.get('password');
|
||||||
const res = await fetch('/api/auth', {{method: 'POST', body}});
|
const res = await fetch('/api/auth', {{method: 'POST', body}});
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
if (res.ok) {{
|
if (res.ok) {{
|
||||||
|
if (passwordChanged || res.headers?.get('X-Hub-Reauth') === '1') {{
|
||||||
|
setOwnerPasswordRememberEnabled(false);
|
||||||
|
form.password.value = '';
|
||||||
|
form.password_confirm.value = '';
|
||||||
|
window.location.replace('/login');
|
||||||
|
return;
|
||||||
|
}}
|
||||||
const nextCurrentPassword = form.password.value ? String(form.password.value || '') : String(form.current_password.value || '');
|
const nextCurrentPassword = form.password.value ? String(form.password.value || '') : String(form.current_password.value || '');
|
||||||
if (ownerPasswordRememberEnabled()) setOwnerPasswordRememberEnabled(true, nextCurrentPassword);
|
if (ownerPasswordRememberEnabled()) setOwnerPasswordRememberEnabled(true, nextCurrentPassword);
|
||||||
setAuthMessage(text || 'Доступ обновлен');
|
setAuthMessage(text || 'Доступ обновлен');
|
||||||
@@ -14827,30 +14835,6 @@ a{{display:inline-flex;margin-top:18px;color:#93c5fd}}
|
|||||||
return
|
return
|
||||||
self.send_bytes(401, login_html(error_text or "Неверный логин или пароль").encode("utf-8"), "text/html; charset=utf-8")
|
self.send_bytes(401, login_html(error_text or "Неверный логин или пароль").encode("utf-8"), "text/html; charset=utf-8")
|
||||||
|
|
||||||
def update_auth(self):
|
|
||||||
payload = self.read_payload()
|
|
||||||
auth = load_auth()
|
|
||||||
current_password = payload.get("current_password", "")
|
|
||||||
if not verify_login(auth.get("username", ""), current_password):
|
|
||||||
self.send_text(403, "Текущий пароль неверный")
|
|
||||||
return
|
|
||||||
username = payload.get("username", auth.get("username", "admin"))
|
|
||||||
new_password = payload.get("password", "")
|
|
||||||
confirm = payload.get("password_confirm", "")
|
|
||||||
if new_password:
|
|
||||||
if new_password != confirm:
|
|
||||||
self.send_text(400, "Новый пароль и повтор не совпадают")
|
|
||||||
return
|
|
||||||
if len(new_password) < MIN_PASSWORD_LENGTH:
|
|
||||||
self.send_text(400, f"Новый пароль должен быть минимум {MIN_PASSWORD_LENGTH} символа")
|
|
||||||
return
|
|
||||||
save_auth(username, new_password)
|
|
||||||
else:
|
|
||||||
clean = clean_username(username)
|
|
||||||
auth["username"] = clean
|
|
||||||
save_auth_state(auth)
|
|
||||||
self.send_text(200, "Доступ к Hub обновлен")
|
|
||||||
|
|
||||||
def update_auth(self):
|
def update_auth(self):
|
||||||
payload = self.read_payload(keep_blank_values=True)
|
payload = self.read_payload(keep_blank_values=True)
|
||||||
auth = normalize_auth_state(load_auth())
|
auth = normalize_auth_state(load_auth())
|
||||||
@@ -14901,6 +14885,18 @@ a{{display:inline-flex;margin-top:18px;color:#93c5fd}}
|
|||||||
)
|
)
|
||||||
auth["updated_at"] = now_ts()
|
auth["updated_at"] = now_ts()
|
||||||
save_auth_state(auth)
|
save_auth_state(auth)
|
||||||
|
if new_password:
|
||||||
|
revoke_hub_session(token=self.current_session_token())
|
||||||
|
if self.legacy_admin_ok():
|
||||||
|
token = secrets.token_urlsafe(32)
|
||||||
|
atomic_write_text(SESSION_TOKEN_FILE, token + "\n", mode=0o600)
|
||||||
|
self.app.session_token = token
|
||||||
|
self.send_bytes(
|
||||||
|
200,
|
||||||
|
"Доступ к Hub обновлен".encode("utf-8"),
|
||||||
|
extra_headers=[("Set-Cookie", self.clear_session_cookie()), ("X-Hub-Reauth", "1")],
|
||||||
|
)
|
||||||
|
return
|
||||||
self.send_text(200, "Доступ к Hub обновлен")
|
self.send_text(200, "Доступ к Hub обновлен")
|
||||||
|
|
||||||
def build_auth_meta(self):
|
def build_auth_meta(self):
|
||||||
|
|||||||
Reference in new issue
Block a user