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(show-page): preserve scoped email entitlements
Maxf5edee405738
diff --git a/docs/plans/show-page-email-access.md b/docs/plans/show-page-email-access.mdindex 9da002d6b..616320329 100644--- a/docs/plans/show-page-email-access.md+++ b/docs/plans/show-page-email-access.md@@ -17,6 +17,9 @@ Anonymous Public links remain an independent sharing switch.`vibe_show_page_id` claim.- Existing Instance owner, email, domain, group, and public-instance access winsbefore the ShowPage-only grant so existing users keep their broader access.+- When a broader user also has the target ShowPage email grant, the broader+ source and role remain unchanged while the signed `vibe_show_page_id` is+ retained as an independent exact-page entitlement.- A `show_page_email` browser session may serve only the exact`/show/<vibe_show_page_id>` route subtree and required public static assets.Workbench, Chat, other Sessions, Agents, files, Cloud capabilities, APIs, anddiff --git a/storage/resource_access_service.py b/storage/resource_access_service.pyindex 8d9f217b3..9f6c7d98b 100644--- a/storage/resource_access_service.py+++ b/storage/resource_access_service.py@@ -549,8 +549,10 @@ def _policy_allows() -> bool:if context.is_trusted_local:return True+ if resource_kind == "show_page" and context.can_use_show_page(resource_id):+ return Trueif context.instance_access_source == "show_page_email":- return resource_kind == "show_page" and context.can_use_show_page(resource_id)+ return Falseif not context.can_use_resource(resource_kind):return Falseif policy is None:diff --git a/tests/scenario_harness/show_page_email_access.py b/tests/scenario_harness/show_page_email_access.pynew file mode 100644index 000000000..262e03028--- /dev/null+++ b/tests/scenario_harness/show_page_email_access.py@@ -0,0 +1,129 @@+from __future__ import annotations++import os+import tempfile+from pathlib import Path+from unittest.mock import patch++import httpx++from config.v2_config import (+ AgentsConfig,+ PlatformsConfig,+ RemoteAccessConfig,+ RuntimeConfig,+ SlackConfig,+ UiConfig,+ V2Config,+)+from core.show_pages import ShowPageStore+from vibe import remote_access, ui_server+from vibe.ui_server import app+++REMOTE_ORIGIN = "https://alex.avibe.bot"+REMOTE_PEER = {"REMOTE_ADDR": "203.0.113.10"}+++class ShowPageEmailAccessScenarioHarness:+ """Hermetic browser harness for one exact-email Show Page login."""++ def __init__(self) -> None:+ self._tempdir = tempfile.TemporaryDirectory()+ self._environment = patch.dict(+ os.environ,+ {"AVIBE_HOME": str(Path(self._tempdir.name) / "avibe-home")},+ )+ self._environment.start()+ remote_access._oauth_handshakes.clear()+ self.config = self._save_config()+ self.client = app.test_client()+ store = ShowPageStore()+ try:+ store.ensure("session-one")+ store.ensure("session-two")+ finally:+ store.close()++ def _save_config(self) -> V2Config:+ config = V2Config(+ mode="self_host",+ version="v2",+ platform="slack",+ platforms=PlatformsConfig(enabled=["slack"], primary="slack"),+ slack=SlackConfig(bot_token=""),+ runtime=RuntimeConfig(default_cwd="."),+ agents=AgentsConfig(),+ ui=UiConfig(),+ remote_access=RemoteAccessConfig(),+ )+ cloud = config.remote_access.vibe_cloud+ cloud.enabled = True+ cloud.public_url = REMOTE_ORIGIN+ cloud.client_id = "vr_client_123"+ cloud.instance_id = "inst_123"+ cloud.session_secret = "scenario-session-secret"+ cloud.authorization_endpoint = "https://avibe.bot/oauth/authorize"+ cloud.redirect_uri = f"{REMOTE_ORIGIN}/auth/callback"+ config.save()+ return config++ def begin_login(self, show_page_id: str) -> dict[str, str]:+ next_path = f"/show/{show_page_id}/__show/me"+ response = self.client.get(+ next_path,+ base_url=REMOTE_ORIGIN,+ environ_base=REMOTE_PEER,+ follow_redirects=False,+ )+ assert response.status_code == 302+ authorize_params = httpx.URL(response.headers["Location"]).params+ state = authorize_params["state"]+ state_payload = ui_server._read_oauth_state(+ self.config.remote_access.vibe_cloud.session_secret,+ state,+ )+ assert state_payload is not None+ handshake = remote_access._oauth_handshakes[state_payload["r"]]+ return {+ "next_path": next_path,+ "show_page_id": authorize_params["show_page_id"],+ "state": state,+ "nonce": handshake["nonce"],+ }++ def complete_login(self, handshake: dict[str, str]):+ show_page_id = handshake["show_page_id"]+ exchange_result = {+ "claims": {+ "email": "[email protected]",+ "sub": "guest-1",+ "nonce": handshake["nonce"],+ },+ "session_claims": {+ "vibe_instance_id": "inst_123",+ "vibe_instance_role": "viewer",+ "vibe_instance_access_source": "show_page_email",+ "vibe_show_page_id": show_page_id,+ },+ }+ with patch.object(remote_access, "exchange_oauth_code", return_value=exchange_result):+ return self.client.get(+ f"/auth/callback?code=scenario-code&state={handshake['state']}",+ base_url=REMOTE_ORIGIN,+ environ_base=REMOTE_PEER,+ follow_redirects=False,+ )++ def get(self, path: str):+ return self.client.get(+ path,+ base_url=REMOTE_ORIGIN,+ environ_base=REMOTE_PEER,+ follow_redirects=False,+ )++ def close(self) -> None:+ remote_access._oauth_handshakes.clear()+ self._environment.stop()+ self._tempdir.cleanup()diff --git a/tests/scenarios/auth_setup/catalog.yaml b/tests/scenarios/auth_setup/catalog.yamlindex 07cc3345a..006a15c3b 100644--- a/tests/scenarios/auth_setup/catalog.yaml+++ b/tests/scenarios/auth_setup/catalog.yaml@@ -211,6 +211,13 @@ scenarios:layer: scenariobackend: cloud_managementtest: tests/scenarios/auth_setup/test_auth_setup_scenarios.py::OrganizationManagementAuthScenarioTests::test_subject_mismatch_can_reenter_with_workbench_return_path+ - id: AUTH-SETUP-401+ name: Exact-email Show Page login stays confined to its signed page+ status: covered+ kind: authorization+ layer: scenario+ backend: show_page_email+ test: tests/scenarios/auth_setup/test_auth_setup_scenarios.py::ShowPageEmailAccessScenarioTests::test_exact_email_login_is_confined_to_its_signed_show_page- id: AUTH-SETUP-901name: Codex setup success refreshes runtime before the next turnstatus: covereddiff --git a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py b/tests/scenarios/auth_setup/test_auth_setup_scenarios.pyindex 18f030e03..07aa99463 100644--- a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py+++ b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py@@ -30,6 +30,7 @@ from tests.scenario_harness.organization_management import (REMOTE_ORIGIN,OrganizationManagementScenarioHarness,)+from tests.scenario_harness.show_page_email_access import ShowPageEmailAccessScenarioHarnessfrom vibe import cloud_managementfrom vibe.api import (get_claude_auth,@@ -43,6 +44,30 @@ from vibe.claude_config import ()+class ShowPageEmailAccessScenarioTests(unittest.TestCase):+ def setUp(self):+ self.harness = ShowPageEmailAccessScenarioHarness()+ self.addCleanup(self.harness.close)++ def test_exact_email_login_is_confined_to_its_signed_show_page(self):+ """Scenario: AUTH-SETUP-401"""+ handshake = self.harness.begin_login("session-one")+ self.assertEqual(handshake["show_page_id"], "session-one")++ callback = self.harness.complete_login(handshake)+ self.assertEqual(callback.status_code, 302)+ self.assertEqual(callback.headers["Location"], handshake["next_path"])++ exact = self.harness.get(handshake["next_path"])+ other = self.harness.get("/show/session-two/__show/me")+ api = self.harness.get("/api/show-pages")+ self.assertEqual(exact.status_code, 200)+ self.assertEqual(exact.get_json(), {"authenticated": False, "canAnnotate": False})+ self.assertEqual(other.status_code, 403)+ self.assertEqual(other.get_json()["error"], "show_page_access_forbidden")+ self.assertEqual(api.status_code, 403)++class _FakeNextTurnRuntime:def __init__(self):self.refreshed = Falsediff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 7c489e0d3..b0d81397f 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -118,15 +118,18 @@ def test_show_page_email_context_requires_and_matches_one_exact_target() -> None"vibe_instance_access_source": "show_page_email",})- unexpected_target = context_from_session_payload(+ broader_target = context_from_session_payload({- "vibe_instance_role": "viewer",+ "vibe_instance_role": "editor","vibe_instance_access_source": "email","vibe_show_page_id": "session-one",})assert missing_target.can_read_instance is False- assert unexpected_target.can_read_instance is False+ assert broader_target.can_read_instance is True+ assert broader_target.can_chat is True+ assert broader_target.can_use_show_page("session-one") is True+ assert broader_target.can_use_show_page("session-two") is Falseelevated_role = context_from_session_payload({diff --git a/tests/test_resource_acl_show_pages.py b/tests/test_resource_acl_show_pages.pyindex b3a35ff50..7b25a8dab 100644--- a/tests/test_resource_acl_show_pages.py+++ b/tests/test_resource_acl_show_pages.py@@ -151,6 +151,39 @@ def test_show_page_email_context_bypasses_audience_only_for_its_signed_page(store.close()+def test_broader_instance_context_unions_its_signed_show_page_entitlement(+ monkeypatch, tmp_path+) -> None:+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ store = _seed_show_pages_with_policies()+ context = resource_access_service.ResourceUserContext(+ subject="member-1",+ email="[email protected]",+ instance_role="editor",+ instance_access_source="email",+ show_page_id="ses-private",+ is_remote=True,+ )+ try:+ with store.engine.connect() as connection:+ assert resource_access_service.can_use_resource(+ context,+ "show_page",+ "ses-private",+ connection=connection,+ )+ assert not resource_access_service.can_use_resource(+ context,+ "show_page",+ "ses-scope",+ connection=connection,+ )+ assert context.can_chat+ assert context.can_use_resource("agent")+ finally:+ store.close()++def test_remote_show_page_list_and_direct_requests_enforce_policy(monkeypatch, tmp_path) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex b0ed67fdc..5e6eb4d0e 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -224,15 +224,18 @@ def test_show_page_oidc_claim_shape_fails_closed(monkeypatch, tmp_path):with pytest.raises(remote_access.OAuthCodeExchangeError, match="invalid_show_page_id"):remote_access.session_claims_from_oidc(config, base)- with pytest.raises(remote_access.OAuthCodeExchangeError, match="invalid_show_page_id"):- remote_access.session_claims_from_oidc(- config,- {- **base,- "vibe_instance_access_source": "email",- "vibe_show_page_id": "session-one",- },- )+ broader = remote_access.session_claims_from_oidc(+ config,+ {+ **base,+ "vibe_instance_role": "editor",+ "vibe_instance_access_source": "email",+ "vibe_show_page_id": "session-one",+ },+ )+ assert broader["vibe_instance_access_source"] == "email"+ assert broader["vibe_instance_role"] == "editor"+ assert broader["vibe_show_page_id"] == "session-one"def test_custom_hostname_uses_remote_auth_until_heartbeat_removes_it(monkeypatch, tmp_path):@@ -3005,8 +3008,12 @@ def test_remote_callback_rejects_nonce_mismatch(monkeypatch, tmp_path):assert 'href="/dashboard"' in response.text-def test_remote_callback_rejects_show_page_email_token_for_a_different_page(- monkeypatch, tmp_path+ ("access_source", "instance_role"),+ [("show_page_email", "viewer"), ("email", "editor")],+)+def test_remote_callback_rejects_signed_entitlement_for_a_different_page(+ monkeypatch, tmp_path, access_source, instance_role):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -3039,8 +3046,8 @@ def test_remote_callback_rejects_show_page_email_token_for_a_different_page(},"session_claims": {"vibe_instance_id": "inst_123",- "vibe_instance_role": "viewer",- "vibe_instance_access_source": "show_page_email",+ "vibe_instance_role": instance_role,+ "vibe_instance_access_source": access_source,"vibe_show_page_id": "session-two",},},diff --git a/ui/src/components/workbench/ShowPageEmailAccessEditor.tsx b/ui/src/components/workbench/ShowPageEmailAccessEditor.tsxindex b661f837a..6ed14a56b 100644--- a/ui/src/components/workbench/ShowPageEmailAccessEditor.tsx+++ b/ui/src/components/workbench/ShowPageEmailAccessEditor.tsx@@ -4,9 +4,13 @@ import { CloudOff, Loader2, Mail, Plus, RefreshCw, X } from 'lucide-react';import { useTranslation } from 'react-i18next';import { Button } from '@/components/ui/button';+import { ConfirmDialog } from '@/components/ui/confirm-dialog';import { Input } from '@/components/ui/input';import { ApiError, useApi } from '@/context/ApiContext';-import { normalizeShowPageAuthorizedEmail } from '@/lib/showPageAccess';+import {+ normalizeShowPageAuthorizedEmail,+ requiresShowPageEmailRevocationConfirmation,+} from '@/lib/showPageAccess';type EmailAccessGate = 'idle' | 'loading' | 'ready' | 'unavailable' | 'error';@@ -35,6 +39,7 @@ export function ShowPageEmailAccessEditor({const [draft, setDraft] = useState('');const [draftInvalid, setDraftInvalid] = useState(false);const [saving, setSaving] = useState(false);+ const [confirmNarrowing, setConfirmNarrowing] = useState(false);const generationRef = useRef(0);const load = useCallback(async () => {@@ -61,6 +66,7 @@ export function ShowPageEmailAccessEditor({setDraft('');setDraftInvalid(false);setSaving(false);+ setConfirmNarrowing(false);if (active && canManage) void load();return () => {generationRef.current += 1;@@ -85,8 +91,9 @@ export function ShowPageEmailAccessEditor({setDraftInvalid(false);};- const save = async () => {+ const commit = async () => {if (!dirty || saving || draft.trim()) return;+ setConfirmNarrowing(false);setSaving(true);try {const result = await api.replaceShowPageAuthorizedEmails(sessionId, emails);@@ -101,135 +108,154 @@ export function ShowPageEmailAccessEditor({}};+ const save = () => {+ if (!dirty || saving || draft.trim()) return;+ if (requiresShowPageEmailRevocationConfirmation(savedEmails, emails)) {+ setConfirmNarrowing(true);+ return;+ }+ void commit();+ };+return (- <div className="space-y-2.5 border-t border-border pt-2.5">- <div className="flex items-start gap-2">- <Mail className="mt-0.5 size-3.5 shrink-0 text-muted" />- <div className="min-w-0">- <div className="text-xs font-medium">{t('chat.showPage.emailAccess')}</div>- <p className="mt-0.5 text-[11px] leading-snug text-muted">- {t('chat.showPage.emailAccessDesc')}- </p>+ <>+ <div className="space-y-2.5 border-t border-border pt-2.5">+ <div className="flex items-start gap-2">+ <Mail className="mt-0.5 size-3.5 shrink-0 text-muted" />+ <div className="min-w-0">+ <div className="text-xs font-medium">{t('chat.showPage.emailAccess')}</div>+ <p className="mt-0.5 text-[11px] leading-snug text-muted">+ {t('chat.showPage.emailAccessDesc')}+ </p>+ </div></div>- </div>- {gate === 'loading' || gate === 'idle' ? (- <div className="flex items-center gap-1.5 text-[11px] text-muted">- <Loader2 className="size-3.5 animate-spin" />- {t('chat.showPage.loadingEmailAccess')}- </div>- ) : null}+ {gate === 'loading' || gate === 'idle' ? (+ <div className="flex items-center gap-1.5 text-[11px] text-muted">+ <Loader2 className="size-3.5 animate-spin" />+ {t('chat.showPage.loadingEmailAccess')}+ </div>+ ) : null}- {gate === 'unavailable' ? (- <div className="flex items-start gap-1.5 text-[11px] leading-snug text-muted">- <CloudOff className="mt-0.5 size-3.5 shrink-0" />- {t('chat.showPage.emailAccessUnavailable')}- </div>- ) : null}-- {gate === 'error' ? (- <div className="flex items-center justify-between gap-2">- <span className="text-[11px] leading-snug text-destructive">- {t('chat.showPage.emailAccessError')}- </span>- <Button- type="button"- size="icon"- variant="ghost"- className="size-7 shrink-0"- onClick={() => void load()}- aria-label={t('common.retry')}- title={t('common.retry')}- >- <RefreshCw className="size-3.5" />- </Button>- </div>- ) : null}-- {gate === 'ready' ? (- <>- <div className="flex items-start gap-1.5">- <div className="min-w-0 flex-1">- <Input- type="email"- value={draft}- disabled={saving || emails.length >= 64}- onChange={(event) => {- setDraft(event.target.value);- if (draftInvalid) setDraftInvalid(false);- }}- onKeyDown={(event) => {- if (event.key !== 'Enter') return;- event.preventDefault();- addDraft();- }}- placeholder={t('chat.showPage.emailPlaceholder')}- aria-label={t('chat.showPage.emailAccess')}- aria-invalid={draftInvalid || undefined}- className={clsx('h-8 text-xs', draftInvalid && 'border-destructive')}- />- {draftInvalid ? (- <p className="mt-1 text-[11px] text-destructive">- {t('chat.showPage.emailInvalid')}- </p>- ) : null}- </div>+ {gate === 'unavailable' ? (+ <div className="flex items-start gap-1.5 text-[11px] leading-snug text-muted">+ <CloudOff className="mt-0.5 size-3.5 shrink-0" />+ {t('chat.showPage.emailAccessUnavailable')}+ </div>+ ) : null}++ {gate === 'error' ? (+ <div className="flex items-center justify-between gap-2">+ <span className="text-[11px] leading-snug text-destructive">+ {t('chat.showPage.emailAccessError')}+ </span><Buttontype="button"size="icon"- variant="outline"- className="size-8 shrink-0"- disabled={saving || !draft.trim() || emails.length >= 64}- onClick={addDraft}- aria-label={t('chat.showPage.addEmail')}- title={t('chat.showPage.addEmail')}+ variant="ghost"+ className="size-7 shrink-0"+ onClick={() => void load()}+ aria-label={t('common.retry')}+ title={t('common.retry')}>- <Plus className="size-3.5" />+ <RefreshCw className="size-3.5" /></Button></div>+ ) : null}- {emails.length ? (- <div className="max-h-32 divide-y divide-border overflow-y-auto rounded-md border border-border">- {emails.map((email) => (- <div key={email} className="flex min-h-8 items-center gap-2 px-2">- <span className="min-w-0 flex-1 truncate font-mono text-[11px]">{email}</span>- <Button- type="button"- size="icon"- variant="ghost"- className="size-6 shrink-0"- disabled={saving}- onClick={() => setEmails((current) => current.filter((value) => value !== email))}- aria-label={t('chat.showPage.removeEmail', { email })}- title={t('chat.showPage.removeEmail', { email })}- >- <X className="size-3" />- </Button>- </div>- ))}+ {gate === 'ready' ? (+ <>+ <div className="flex items-start gap-1.5">+ <div className="min-w-0 flex-1">+ <Input+ type="email"+ value={draft}+ disabled={saving || emails.length >= 64}+ onChange={(event) => {+ setDraft(event.target.value);+ if (draftInvalid) setDraftInvalid(false);+ }}+ onKeyDown={(event) => {+ if (event.key !== 'Enter') return;+ event.preventDefault();+ addDraft();+ }}+ placeholder={t('chat.showPage.emailPlaceholder')}+ aria-label={t('chat.showPage.emailAccess')}+ aria-invalid={draftInvalid || undefined}+ className={clsx('h-8 text-xs', draftInvalid && 'border-destructive')}+ />+ {draftInvalid ? (+ <p className="mt-1 text-[11px] text-destructive">+ {t('chat.showPage.emailInvalid')}+ </p>+ ) : null}+ </div>+ <Button+ type="button"+ size="icon"+ variant="outline"+ className="size-8 shrink-0"+ disabled={saving || !draft.trim() || emails.length >= 64}+ onClick={addDraft}+ aria-label={t('chat.showPage.addEmail')}+ title={t('chat.showPage.addEmail')}+ >+ <Plus className="size-3.5" />+ </Button></div>- ) : (- <p className="text-[11px] leading-snug text-muted">- {t('chat.showPage.emailAccessEmpty')}- </p>- )}- <div className="flex items-center justify-between gap-3">- <span className="text-[10px] text-muted">{t('chat.showPage.emailAccessLimit')}</span>- <Button- type="button"- size="sm"- variant="outline"- className="h-7"- disabled={!dirty || saving || Boolean(draft.trim())}- onClick={() => void save()}- >- {saving ? <Loader2 className="size-3.5 animate-spin" /> : null}- {t('chat.showPage.applyEmailAccess')}- </Button>- </div>- </>- ) : null}- </div>+ {emails.length ? (+ <div className="max-h-32 divide-y divide-border overflow-y-auto rounded-md border border-border">+ {emails.map((email) => (+ <div key={email} className="flex min-h-8 items-center gap-2 px-2">+ <span className="min-w-0 flex-1 truncate font-mono text-[11px]">{email}</span>+ <Button+ type="button"+ size="icon"+ variant="ghost"+ className="size-6 shrink-0"+ disabled={saving}+ onClick={() => setEmails((current) => current.filter((value) => value !== email))}+ aria-label={t('chat.showPage.removeEmail', { email })}+ title={t('chat.showPage.removeEmail', { email })}+ >+ <X className="size-3" />+ </Button>+ </div>+ ))}+ </div>+ ) : (+ <p className="text-[11px] leading-snug text-muted">+ {t('chat.showPage.emailAccessEmpty')}+ </p>+ )}++ <div className="flex items-center justify-between gap-3">+ <span className="text-[10px] text-muted">{t('chat.showPage.emailAccessLimit')}</span>+ <Button+ type="button"+ size="sm"+ variant="outline"+ className="h-7"+ disabled={!dirty || saving || Boolean(draft.trim())}+ onClick={save}+ >+ {saving ? <Loader2 className="size-3.5 animate-spin" /> : null}+ {t('chat.showPage.applyEmailAccess')}+ </Button>+ </div>+ </>+ ) : null}+ </div>+ <ConfirmDialog+ open={confirmNarrowing}+ onOpenChange={setConfirmNarrowing}+ title={t('organization.resources.narrowTitle')}+ description={t('organization.resources.narrowBody')}+ confirmLabel={t('organization.actions.saveChanges')}+ onConfirm={commit}+ />+ </>);}diff --git a/ui/src/lib/showPageAccess.test.ts b/ui/src/lib/showPageAccess.test.tsindex 07120182a..0543ac3a8 100644--- a/ui/src/lib/showPageAccess.test.ts+++ b/ui/src/lib/showPageAccess.test.ts@@ -7,6 +7,7 @@ import {classifyShowPageAccessProbe,isShowPageVisibilityPayload,normalizeShowPageAuthorizedEmail,+ requiresShowPageEmailRevocationConfirmation,showPageShareCapabilities,showPageHeaderAccess,showPageAudienceLabelKey,@@ -53,6 +54,21 @@ describe('Show Page access policy helpers', () => {expect(normalizeShowPageAuthorizedEmail('guest@')).toBeNull();});+ it('requires confirmation only when saved email access is revoked', () => {+ expect(requiresShowPageEmailRevocationConfirmation(+ ['[email protected]', '[email protected]'],+ ['[email protected]'],+ )).toBe(true);+ expect(requiresShowPageEmailRevocationConfirmation(+ ['[email protected]'],+ ['[email protected]', '[email protected]'],+ )).toBe(false);+ expect(requiresShowPageEmailRevocationConfirmation(+ ['[email protected]', '[email protected]'],+ ['[email protected]', '[email protected]'],+ )).toBe(false);+ });+it('requires at least one group for scoped access and normalizes duplicates', () => {expect(buildShowPageAccessPatch('scope', [], 4)).toBeNull();expect(buildShowPageAccessPatch('scope', ['group-1', ' group-1 ', 'group-2'], 4)).toEqual({diff --git a/ui/src/lib/showPageAccess.ts b/ui/src/lib/showPageAccess.tsindex f9e262749..e85c01779 100644--- a/ui/src/lib/showPageAccess.ts+++ b/ui/src/lib/showPageAccess.ts@@ -46,6 +46,14 @@ export function normalizeShowPageAuthorizedEmail(raw: string): string | null {return SHOW_PAGE_EMAIL_PATTERN.test(normalized) ? normalized : null;}+export function requiresShowPageEmailRevocationConfirmation(+ savedEmails: string[],+ nextEmails: string[],+): boolean {+ const next = new Set(nextEmails);+ return savedEmails.some((email) => !next.has(email));+}+function isShowPageAccess(value: unknown): value is ShowPageAccess {if (!value || typeof value !== 'object') return false;const candidate = value as Partial<ShowPageAccess>;diff --git a/vibe/authorization.py b/vibe/authorization.pyindex af2a27abc..f0255d6d3 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -127,13 +127,9 @@ class AuthorizationContext:return minimum_role is not None and self.has_role(minimum_role)def can_use_show_page(self, show_page_id: str) -> bool:- """Return whether a Show Page-only session targets this exact page."""+ """Return whether the signed session carries this exact page entitlement."""- return bool(- self.instance_access_source == "show_page_email"- and self.show_page_id- and self.show_page_id == show_page_id- )+ return bool(self.show_page_id and self.show_page_id == show_page_id)@propertydef can_use_terminal_files(self) -> bool:@@ -211,7 +207,7 @@ def context_from_session_payload(payload: Mapping[str, Any]) -> AuthorizationConif access_source not in INSTANCE_ACCESS_SOURCES:return AuthorizationContext(is_remote=True)show_page_id = _optional_string(payload.get("vibe_show_page_id"), limit=200)- if (access_source == "show_page_email") != (show_page_id is not None):+ if access_source == "show_page_email" and show_page_id is None:return AuthorizationContext(is_remote=True)if access_source == "show_page_email" and role != "viewer":return AuthorizationContext(is_remote=True)diff --git a/vibe/remote_access.py b/vibe/remote_access.pyindex 13c7848e8..40d60e199 100644--- a/vibe/remote_access.py+++ b/vibe/remote_access.py@@ -4193,9 +4193,7 @@ def session_claims_from_oidc(config: V2Config, claims: Mapping[str, Any]) -> dic"vibe_instance_access_source": access_source,}show_page_claim_present = "vibe_show_page_id" in claims- if access_source == "show_page_email":- if instance_role != "viewer":- raise OAuthCodeExchangeError("invalid_instance_role")+ if show_page_claim_present:show_page_id = _oidc_claim_string(claims.get("vibe_show_page_id"),reason="invalid_show_page_id",@@ -4204,8 +4202,10 @@ def session_claims_from_oidc(config: V2Config, claims: Mapping[str, Any]) -> dicif "/" in show_page_id or "\\" in show_page_id:raise OAuthCodeExchangeError("invalid_show_page_id")session_claims["vibe_show_page_id"] = show_page_id- elif show_page_claim_present:+ elif access_source == "show_page_email":raise OAuthCodeExchangeError("invalid_show_page_id")+ if access_source == "show_page_email" and instance_role != "viewer":+ raise OAuthCodeExchangeError("invalid_instance_role")raw_authorization_revision = claims.get(_AUTHORIZATION_REVISION_KEY)if raw_authorization_revision is None:if _authorization_revision_sync_configured(config):diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 68ef23589..b71937cfd 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -6167,7 +6167,7 @@ def remote_access_auth_callback():session_claims = result.get("session_claims")if not isinstance(session_claims, dict):raise remote_access.OAuthCodeExchangeError("invalid_session_claims")- if session_claims.get("vibe_instance_access_source") == "show_page_email" and (+ if "vibe_show_page_id" in session_claims and (not isinstance(expected_show_page_id, str)or session_claims.get("vibe_show_page_id") != expected_show_page_id):