Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(auth): invalidate private to scoped access

Maxvintc5f5d19a21cd
diff --git a/storage/resource_access_service.py b/storage/resource_access_service.py
index 82e779c18..45f6fba27 100644
--- a/storage/resource_access_service.py
+++ b/storage/resource_access_service.py
@@ -705,6 +705,8 @@ def resource_policy_narrowed(
updated_level = str(updated.get("access_level") or "")
if previous_level == "public":
return updated_level in {"scope", "private"}
+ if previous_level == "private":
+ return updated_level == "scope"
if previous_level != "scope":
return False
if updated_level == "private":
diff --git a/tests/test_resource_access_service.py b/tests/test_resource_access_service.py
index a1faddb81..2088db10c 100644
--- a/tests/test_resource_access_service.py
+++ b/tests/test_resource_access_service.py
@@ -93,6 +93,37 @@ def test_policy_evaluation_private_public_scope_and_missing_group_context(tmp_pa
engine.dispose()
+ ("previous_level", "previous_groups", "updated_level", "updated_groups", "expected"),
+ [
+ ("public", [], "public", [], False),
+ ("public", [], "scope", ["group-engineering"], True),
+ ("public", [], "private", [], True),
+ ("scope", ["group-engineering"], "public", [], False),
+ ("scope", ["group-engineering"], "scope", ["group-engineering", "group-sales"], False),
+ ("scope", ["group-engineering", "group-sales"], "scope", ["group-engineering"], True),
+ ("scope", ["group-engineering"], "private", [], True),
+ ("private", [], "private", [], False),
+ ("private", [], "public", [], False),
+ ("private", [], "scope", ["group-sales"], True),
+ ],
+)
+def test_resource_policy_narrowing_matrix(
+ previous_level: str,
+ previous_groups: list[str],
+ updated_level: str,
+ updated_groups: list[str],
+ expected: bool,
+) -> None:
+ assert (
+ resource_access_service.resource_policy_narrowed(
+ {"access_level": previous_level, "group_ids": previous_groups},
+ {"access_level": updated_level, "group_ids": updated_groups},
+ )
+ is expected
+ )
+
+
def test_no_policy_is_local_private_but_instance_owner_keeps_legacy_access(tmp_path) -> None:
db = tmp_path / "vibe.sqlite"
run_migrations(db)
diff --git a/tests/test_resource_acl_vaults.py b/tests/test_resource_acl_vaults.py
index 13c23ff30..c4954657e 100644
--- a/tests/test_resource_acl_vaults.py
+++ b/tests/test_resource_acl_vaults.py
@@ -549,6 +549,7 @@ def test_remote_external_guest_cannot_create_vault_secret(vault) -> None:
[
("public", None, "scope", ["group-engineering"]),
("scope", ["group-engineering", "group-sales"], "scope", ["group-engineering"]),
+ ("private", None, "scope", ["group-sales"]),
],
)
def test_narrowed_vault_policy_revokes_active_grants(