Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(auth): refresh exempt remote sessions
Maxvintb03215072134
diff --git a/tests/test_remote_access_vibe_cloud.py b/tests/test_remote_access_vibe_cloud.pyindex dd75433b7..9df5b9dd1 100644--- a/tests/test_remote_access_vibe_cloud.py+++ b/tests/test_remote_access_vibe_cloud.py@@ -2023,3 +2023,20 @@ def test_cloud_token_for_request_returns_none_without_valid_session(monkeypatch)assert remote_access.cloud_token_for_request(config, None) is Noneassert remote_access.cloud_token_for_request(config, "bogus.cookie") is None+++def test_cloud_token_for_request_rejects_stale_authorization(monkeypatch) -> None:+ config = _cloud_broker_config()+ cookie = remote_session_cookie(config, "[email protected]", "user-1")+ mint_called = False++ def fake_mint(*args, **kwargs):+ nonlocal mint_called+ mint_called = True+ return {"access_token": "must-not-mint", "expires_in": 60}++ monkeypatch.setattr(remote_access, "session_needs_authorization_refresh", lambda payload: True)+ monkeypatch.setattr(remote_access, "mint_cloud_token", fake_mint)++ assert remote_access.cloud_token_for_request(config, cookie) is None+ assert mint_called is Falsediff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex b4c14190a..8686d2b59 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -663,6 +663,53 @@ def _forged_session_cookie(config: V2Config, exp: int, *, email: str = "alex@exareturn f"{payload_text}.{signature}"+def test_remote_session_probe_reports_unauthenticated_when_authorization_refresh_required(monkeypatch, tmp_path):+ import time as _time++ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ near_exp = int(_time.time()) + (remote_access.SESSION_TTL_SECONDS // 2) - 60+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ _forged_session_cookie(config, near_exp),+ domain="alex.avibe.bot",+ )++ response = client.get("/api/session", base_url="https://alex.avibe.bot")++ assert response.status_code == 200+ assert response.get_json() == {"remote": True, "authenticated": False}+++def test_cloud_token_requires_authorization_refresh_before_mint(monkeypatch, tmp_path):+ import time as _time++ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ near_exp = int(_time.time()) + (remote_access.SESSION_TTL_SECONDS // 2) - 60+ mint_called = False++ def fake_mint(*args, **kwargs):+ nonlocal mint_called+ mint_called = True+ return {"access_token": "must-not-mint", "expires_in": 60}++ monkeypatch.setattr(remote_access, "mint_cloud_token", fake_mint)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ _forged_session_cookie(config, near_exp),+ domain="alex.avibe.bot",+ )++ response = client.get("/api/cloud/token", base_url="https://alex.avibe.bot")++ assert response.status_code == 401+ assert response.get_json()["error"] == "remote_access_authorization_refresh_required"+ assert mint_called is False++def test_remote_host_does_not_renew_fresh_cookie(monkeypatch, tmp_path):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)diff --git a/vibe/remote_access.py b/vibe/remote_access.pyindex 34ccba231..8d627574d 100644--- a/vibe/remote_access.py+++ b/vibe/remote_access.py@@ -617,7 +617,7 @@ def cloud_token_for_request("""config = config or V2Config.load()payload = parse_session_cookie(config, cookie_value)- if payload is None:+ if payload is None or session_needs_authorization_refresh(payload):return Noneemail = str(payload.get("email", "")).strip()sub = str(payload.get("sub", "")).strip()diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 9ef63dd24..4169127e2 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -4744,7 +4744,7 @@ def api_session():payload = remote_access.parse_session_cookie(config, request.cookies.get(remote_access.SESSION_COOKIE_NAME))- if payload is None:+ if payload is None or remote_access.session_needs_authorization_refresh(payload):response = jsonify({"remote": True, "authenticated": False})else:response = jsonify(@@ -5015,8 +5015,12 @@ def api_cloud_token():config = _load_remote_access_config()if config is None:return jsonify({"error": "cloud_unavailable"}), 503+ cookie_value = request.cookies.get(remote_access.SESSION_COOKIE_NAME)+ payload = remote_access.parse_session_cookie(config, cookie_value)+ if payload is not None and remote_access.session_needs_authorization_refresh(payload):+ return jsonify({"ok": False, "error": "remote_access_authorization_refresh_required"}), 401result = remote_access.cloud_token_for_request(- config, request.cookies.get(remote_access.SESSION_COOKIE_NAME)+ config, cookie_value)if result is None:return jsonify({"error": "cloud_unavailable"}), 503