Skip to content

feat(meetings): connect a calendar's credentials and OAuth from Settings - #8081

Closed
kaizawa97 wants to merge 2 commits into
kirodotdev:mainfrom
kaizawa97:pr/meetings-calendar-settings-ui
Closed

kaizawa97 wants to merge 2 commits into
kirodotdev:mainfrom
kaizawa97:pr/meetings-calendar-settings-ui

Conversation

@kaizawa97

@kaizawa97 kaizawa97 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2190 (pr/meetings-calendar-providers). This branch is #2190's head 8dc1f9fe80 plus one commit, feat(meetings): connect a calendar's credentials and OAuth from Settings; only that commit is for review here. It becomes the whole diff once #2190 merges.

Problem / Motivation

Goal: Let a user connect CalDAV, Google or Microsoft 365 from Settings without the page ever seeing a stored value, and without a second, hand-kept list of what each provider needs.

#2190 adds the CalDAV, Google Calendar and Microsoft 365 providers and the routes to store their credentials and run the OAuth handshake, but no screen calls them. Settings → Calendar shows a provider picker and a source field and nothing else, so the three new providers can only be connected by hand-crafting PUT /calendar/credentials and POST /calendar/oauth/start requests.

Why it matters

A provider nobody can configure from the product is not shipped. Until this lands, the calendar picker offers three choices that lead nowhere for anyone not comfortable with curl, and #2190's write-only store and PKCE OAuth protect credentials that no user can enter.

Not a goal

What changed (motivation → approach → change)

The form's shape comes from the backend. #2190's write path already owns the per-provider field allowlist (_CREDENTIAL_FIELDS) and the OAuth client map (_OAUTH_CLIENTS); GET /calendar/credentials in routes/calendar.py now returns them as providers, so the fields a user sees and the fields a PUT accepts cannot disagree. components/CalendarCredentials.tsx (new) renders them with the dashboard's write-only SecretField: a typed value is sent, a removed field is sent as null, an untouched field is not sent. The status row shows a badge — Connected only for an OAuth provider holding a refresh token, Credentials saved for a complete password provider — with Disconnect beside it; the action row is Save credentials and Sign in with {provider}, which opens the consent page and always offers it as a link as well. Google and Microsoft fields link to where their client id comes from. Every failure renders an inline ErrorNotice. SettingsView.tsx mounts the component keyed by provider, so switching provider discards unsaved input instead of saving it under the other provider; api.ts adds the client methods.

The desktop shell opens the consent page in the OS browser, which carries no dashboard token, so dashboard/token_auth.py admits the OAuth callback for GET only (the same method-scoped bypass as the self-authenticating webhooks); the callback's single-use state is its admission, and /calendar/oauth/start still requires the token. 21 strings are added to every catalog under website/src/i18n/locales/ (for example locales/en.json) with translator notes in en.context.json, and docs/system-specs/modules/meetings.md gains #2190's routes and a Credentials in Settings section.

Backwards compatibility

Compatible: the GET gains one field, and the only auth change admits GET on the callback path.

Tests

  • website/src/test/MeetingsCalendarCredentials.test.tsx — schema-driven fields; only typed values are sent and none echoed; null for a removed field; the draft kept on a failed save; Disconnect through the forget route and outside the Save / Sign in row; sign-in disabled without a client id; the consent link always offered; ErrorNotice with and without the agent hand-off; badge states; setup links.
  • website/src/test/MeetingsSettingsViewCoverage.test.tsx — switching provider after typing a secret, or after pressing Remove, saves nothing from the old provider (both fail without the key).
  • test/test_meetings_oauth_callback_auth.py — through the real middleware: a tokenless GET reaches the callback, other methods are denied, and /calendar/oauth/start still needs the token.
  • test/test_meetings_calendar_routes.py — the GET's providers map equals the allowlist and omits ics.

Manual verification

The OAuth consent has not been completed against a live Google or Microsoft 365 tenant, from the browser or the desktop shell; that needs a registered client. The handshake is covered by #2190's tests, and this PR's side is covered at the window.open boundary and by the callback-admission test.

Screenshots / video

Not captured for this head. The earlier screenshots predate the badge, status-row and error-notice changes, and the committed PNGs were removed from the branch; fresh captures of Settings → Calendar (CalDAV not connected / credentials saved, Google before and after a client id) are still owed and will be added to this description.

Related Issues

no linked issue: feature work from the Meetings stack; depends on #2190.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kaizawa97
kaizawa97 requested review from a team and pepmach September 3, 2026 04:48
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 3, 2026
@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-settings-ui branch from 7af15db to 4530692 Compare September 3, 2026 05:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 3, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • PR #2190 is OVERLAPPING relative to this PR. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #2190: REBASE. 8081 contains this PR verbatim, but as the dependent half of an author-declared stack: 2190 is the base. Closing 2190 in favour of 8081 would only be right if the two are collapsed into one PR — and 8081 carries the same routes/calendar.py conflict with merged PR #8080, so collapsing removes no rebase work. Keep 2190 as the landing unit and let 8081 rebase onto main afterwards. Files: src/kiro_crew/apps/builtins/meetings/backend/credentials.py, src/kiro_crew/apps/builtins/meetings/backend/routes/calendar.py. The two independent directions used different labels; the matrix conservatively retains OVERLAPPING for coordination.
  • This PR is OVERLAPPING with PR #7194. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #8081: REBASE. Same app and the same shared append points, entirely different user goal. Independent; no coordination needed beyond ordinary locale-file merges. Files: website/src/apps/meetings/api.ts and src/kiro_crew/apps/builtins/meetings/backend/constants.py. The two independent directions used different labels; the matrix conservatively retains OVERLAPPING for coordination.
  • This PR is OVERLAPPING with PR #8080. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #8081: REBASE. PR #8080 landed on 2026-09-03T09:27:25Z, after this branch was cut, and is what produced the 'merge conflict' label and the PR #8080 cross-reference on this PR's timeline. Read-only git merge-tree against live origin/main confirms exactly two content conflicts (docs/system-specs/modules/meetings.md and backend/routes/calendar.py); everything else auto-merges. Nothing in PR #8080 implements any part of PR #8081. Files: src/kiro_crew/apps/builtins/meetings/backend/routes/calendar.py, docs/system-specs/modules/meetings.md, src/kiro_crew/apps/builtins/meetings/backend/constants.py, routes/__init__.py, website/src/apps/meetings/api.ts, test/test_meetings_routes.py.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@dwu96 dwu96 added the needs-pr-triage PR scanner: awaiting automated triage label Sep 7, 2026
@NicholasRBowers NicholasRBowers added needs-author-decision PR blocked on author input and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 7, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:

When you've addressed these, the pipeline will re-assess on its next cycle.

@bolichen97
bolichen97 force-pushed the pr/meetings-calendar-settings-ui branch from 4530692 to c53d1a2 Compare September 8, 2026 17:29
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main 8534cbf by a maintainer as part of the 2026-09-08 open-PR audit. Four conflicts:

  • routes/__init__.py: kept main's one-line /calendar/providers registration, added the 5 new credential/OAuth routes above it.
  • routes/calendar.py: import-list only, took the added BadRequest, audit.
  • security.py: gone (split into security/), so "workspace/meetings" moved verbatim into security/paths.py's _CREW_SECRET_LEAVES. The _GENERAL_PURPOSE_PARENT_DIRS hunk was dropped: that set and the cd-taint mechanism it excluded from no longer exist on main.
  • docs/system-specs/modules/meetings.md: kept both new sections.

Main's new test_sandbox_governance_mask.py requires every crew secret leaf to have a sandbox disposition, so "workspace/meetings" was also added to sandbox._CREW_HIDDEN_LEAVES (no carve-out needed, the backend runs in-process).

Ran locally: black/isort/flake8 on changed files, the 4 meetings test files (509 passed), all test_sandbox_* (1400 passed), tsc --noEmit, and the 2 touched vitest files.

Please review the resolution. A maintainer push makes the maintainer the last pusher, so a second approver is needed under the repo's last-push rule. Reply if anything looks wrong.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of 3117c529d1e3a479b1a40fd97a2da5fd45892796 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The Google/Microsoft connect path rests on an unverified provider claim — "loopback redirect on any port, without re-registration" — never completed against a live tenant.

Not justified as shipped

  • Item 3 — premise risk: the routes docstring asserts "Both Google (Desktop app) and Microsoft (Mobile and desktop applications) accept a loopback redirect on any port," while the description admits "The OAuth consent has not been completed against a live Google or Microsoft 365 tenant"; the origin-derived _redirect_uri also emits non-loopback origins (a LAN-addressed dashboard), which neither vendor accepts for desktop clients — the flow then dies at the provider with a message that does not name the cause.
    Clears when: the consent completes against a live Google and a live Microsoft 365 tenant, from browser and desktop shell (the verification the description already owes).

What this change ships

Inventory (10 items) — 9 justified

Intent: let a user connect CalDAV, Google, or Microsoft 365 from Settings with no stored value ever reaching the page — ADDITION (diff includes the declared stacked base #2190).

  1. Settings → Calendar gains a schema-driven, write-only credential form under the provider picker — justified
  2. Status badge (Connected / Credentials saved / partial) with Disconnect on the status row — justified
  3. "Sign in with {provider}" opens the consent page, link always offered — premise risk (see above)
  4. GET /calendar/credentials now also returns each provider's form shape — justified
  5. OAuth callback admitted without a dashboard token, GET only, via the existing bypass map — justified
  6. Three new connectable calendar providers (CalDAV, Google, Microsoft 365) behind one gated fetch path — justified
  7. Write-only credential store plus PKCE OAuth flow and their routes — justified
  8. New hidden top-level data-home directory meetings-credentials, masked and precreated before every spawn — justified
  9. 21 new strings in every locale catalog — justified
  10. meetings.md and security.md specs updated in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] 3117c52

Description read

[DESCRIPTION-READ] 6ba77d1b1f7bb7a29e0243391f8253db943a1e80b6a606d371afe9b05c03e670

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — 🔴 BLOCK

UX-level review of 3117c529d1e3a479b1a40fd97a2da5fd45892796 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: BLOCK

Cannot evaluate: missing every screenshot of the new Settings → Calendar credentials UI — the description itself says captures are "still owed."

Evidence gaps

  • CalDAV states — "Not connected" empty form, and "Credentials saved" with masked Username/Password plus the Disconnect button: screenshot of Settings → Calendar for CalDAV in both states.
  • OAuth provider states — Google/Microsoft with no client id (disabled "Sign in with {provider}" + "Save a client ID first, then sign in" hint) and after sign-in ("Connected" badge): before/after screenshots.
  • Error states — the inline ErrorNotice for a failed load (credentialsUnavailable, with ask-agent hand-off) and a failed save keeping the draft: screenshot of either.
  • Post-sign-in fallback — the "Open the sign-in page" link that renders after connectStarted: screenshot.

Watch

  • "Disconnect" (forget.mutate()) wipes all stored secrets in one click — no confirm, no undo, and values are never shown so a client secret must be re-fetched from the provider console; rare action but unrecoverable in-app. Restate the action in a confirm ("Disconnect Google Calendar") or offer undo.

Suggestions

  • connectStarted toast says "use the link below," but a toast has no "below" — name the target: "use the 'Open the sign-in page' link in the form."

[UX-REVIEWED] 3117c52

Description read

[DESCRIPTION-READ] 175abe2ae61ec1c9370877b58330efa68ff68c21937e376c37f3b427e9bf3220

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🔴 BLOCK (blocking)

Design-level review of 3117c529d1e3a479b1a40fd97a2da5fd45892796 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Cannot evaluate: missing screenshots of the new Settings → Calendar credentials panel — no rendered evidence of this revision exists.

Blockers

Missing rendered evidence for a new user-visible surface.
The diff adds website/src/apps/meetings/components/CalendarCredentials.tsx (status badge row, Disconnect placement, secret fields, Save / Sign-in action row, consent-link fallback) and mounts it in SettingsView.tsx; the evidence file records 0 images and 0 committed captures (0 transport failures), and the description says "Not captured for this head … fresh captures … are still owed." A reviewer cannot judge the shape of a surface never seen — badge/Disconnect layout, error-notice placement, and the OAuth field + setup-link rendering are all unverifiable.
Fix: capture the states the description itself names (CalDAV not connected / credentials saved; Google before and after a client id) and attach them.
Clears when: the description carries downloaded image attachments (or committed screenshots) of this head's Settings → Calendar credential panel in those states.

Watch

The live OAuth handshake is unrun: "loopback redirect on any port" acceptance by Google/Microsoft and the origin-derived redirect URI rest on provider documentation, so a rejection would surface only at the consent screen for the first real user.
Clears when: one completed consent against a registered Google or Microsoft client (browser or desktop shell) is reported in the PR.

[DESIGN-REVIEWED] 3117c52

Description read

[DESCRIPTION-READ] dadc04345119982e09bfc36d6226f97f9a125a36949d11074e593ccbd1550c83

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 3117c529d1e3a479b1a40fd97a2da5fd45892796 via the fork AI-review pipeline; updated in place on each push.

Review details

Advisory only — the calendar credential store's _StoreUnreadable is an uncaught RuntimeError on four new routes, but no blocking-class defect survived falsification.

FINDING — src/kiro_crew/apps/builtins/meetings/backend/credentials.py:150 — class _StoreUnreadable(RuntimeError) is matched by none of the handlers' except clauses (guarded catches only (store.MeetingsPathError, BadRequest), handle_oauth_start only cal.CalendarError, handle_oauth_callback only (cal.CalendarError, BadRequest)), so an unreadable calendar-credentials.json turns Save/Disconnect/Sign-in into an opaque 500 and turns the consent callback into a browser 500 after the authorization code was consumed, discarding the fresh refresh token, while the display path's _read_sync swallow shows a normal-looking "not connected" form → Fix: catch _StoreUnreadable at the four route boundaries (or derive it from CalendarError) and answer with a message naming the unreadable store path.

[OPUS-REVIEWED] 3117c52

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Credential failures lack ErrorNotice; three sibling buttons span=5311fb8b5a5a

fixed in 33ed7af.
Same change as the Opus lane: ErrorNotice for load, save, disconnect and sign-in failures, and Disconnect moved out of the Save / Sign in row, with tests for both.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Disconnect can be undone by an in-flight token refresh span=93ccc502637d

fixed in 33ed7af.
Fixed in #2190's 56b8ba6603, which this PR is restacked on: the refresh path writes through credentials.write_for(..., only_if=...) under _STORE_LOCK and only when the refresh token it started from is still stored, so a Disconnect that lands mid-refresh is not undone.
#2190 carries the race test.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Cross-origin redirects resend OAuth secrets span=180cb23267a1

rebutted in 33ed7af.
token_url is the hardcoded, TLS-verified GOOGLE_TOKEN_URL / MICROSOFT_TOKEN_URL, with no configuration seam; producing a cross-origin 307/308 requires compromising the provider's token host, which already receives the body on the first hop.
This is #2190's code, and the adjudication fence means a human override is required.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Docstring says the store is rewritten wholesale span=1911488f13be

fixed in 33ed7af.
Fixed in #2190's current head; the string is gone from credentials.py.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Docstring says three implementations ship span=ce02a6fc8e74

fixed in 33ed7af.
Fixed in #2190's current head: providers/calendar.py reads "Five implementations ship".

@kaizawa97

Copy link
Copy Markdown
Contributor Author

@bolichen97 thanks. The credential store is fixed in the base: #2190 (now 56b8ba6603) moves it to <crew-home>/meetings-credentials/ and registers it in _CREW_SECRET_LEAVES, sandbox._CREW_HIDDEN_LEAVES and _CREW_PRECREATE_HIDDEN_DIR_LEAVES, with test_sandbox_governance_mask.py covering a sandbox spawned before the first save. This PR is restacked on that commit and no longer touches sandbox.py; it is one commit of Settings UI work on top of #2190 (33ed7afab5).

Also in this push: switching the calendar provider now discards unsaved input, so a Google secret typed but not saved cannot be stored under Microsoft or blank Microsoft's stored secret. There is a test for each case.

Still open and needing a person: a live Google / Microsoft 365 consent from the desktop shell, and fresh screenshots. Merge order is #2190 first.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🟡 CONCERNS

Which legitimate operations does 3117c529d1e3a479b1a40fd97a2da5fd45892796 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

the reviewer's own judgement; no confirmed regression

Scope-Verdict: CONCERNS

TIGHTENING: the agent-facing fences around the new calendar credential store, plus the server-side gates the new providers route through -- the ONE threat refused is an agent (file tool or spawned sandboxed command) reading the live calendar credentials (a CalDAV password, Google / Microsoft 365 OAuth refresh + access tokens) out of <crew-home>/meetings-credentials/. The fence hunks: in src/kiro_crew/security/paths.py, _CREW_SECRET_LEAVES gains + "meetings-credentials", ("The DIRECTORY is gated, not the one leaf, because atomic_write's owner-only .tmp sibling holds the same tokens"); in src/kiro_crew/sandbox.py, _MEETINGS_CREDENTIALS_LEAF = "meetings-credentials" is added to both _CREW_HIDDEN_LEAVES and _CREW_PRECREATE_HIDDEN_DIR_LEAVES ("masked here so a spawned command's open(), which never routes through that gate, cannot read a refresh token that stays valid until revoked"). The shell deny composite itself is untouched: the security-package hunk is declaration-only, and test_security_gate_liveness.py's own ratchet comment pins that ("no new control logic and no new matching pass").

ADJUDICATED: 13 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix rows cover the data-home and app-data reads in ~/.kiro/crew spelling, the leaf-name-as-grep-data probes, the sanctioned .venv/bin/python pytest invocation over the two new suites, and a public https curl -o /tmp/... beside the exfil tier's shapes. windows rows cover the same data-home and app-config reads in $env:USERPROFILE\.kiro\crew spelling (Windows has no bind mask, so the tool fence is the only guard there and its spelling must hold), the .venv\Scripts\python.exe pytest lane, and an icacls inspection of the meetings data tree, because the diff's Windows posture rests on restrict_to_owner ACLs. any rows cover git grep/git log over the touched area and the loopback callback curl. One assumed platform behaviour no shell row can probe: the Windows junction guard (is_link_or_junction in credentials._ensure_home/_load_sync) runs inside the gateway process, so no candidate reaches it — named below. Per-leg verdicts are the deterministic fold's to report, not mine.

UNADJUDICATED: most of this tightening lives outside the shell composite (which deliberately has no path tier), so no verdict exists for it and the candidates above probe only accidental coupling:

  • is_sensitive_path file-tool fence. Call path: agent file tool → hooks.on_tool_call path gate → is_sensitive_path → _SENSITIVE_HOME_DIRS, which now carries <prefix>/meetings-credentials for both crew-home prefixes. Candidate inputs I would have submitted: reads of <crew-home>/config.json and <crew-home>/apps/meetings/data/* (the siblings the diff's docstrings promise stay open), a neighbouring name sharing the prefix (<crew-home>/meetings-credentials-old, to prove the matcher is separator-anchored), and the legacy .kirocrew prefix spelling.
  • The sandbox bind mask and pre-spawn materialisation. Call path: namespace spawn → _materialize_maskable_dirs → SENSITIVE_DIRS bind. Candidate inputs: an in-sandbox open() of the meetings app data tree, and the backend's first credential save landing on the precreated empty directory (the new test_sandbox_governance_mask.py class exercises both).
  • The URL gate extension in providers/calendar.py. Call path: settings → provider fetch() → fetch_vetted → vet_url/_normalize_url (https-only, is_global-only address vet). NARROWING, arguable but not confirmable here: a self-hosted CalDAV server on a LAN address or .local name (Nextcloud, Synology, Radicale — a mainstream legitimate deployment of exactly this protocol) is refused by the private-address rule from the feature's first day; likewise a CalDAV REPORT answered with 301/302/303 (a permanently moved collection) is refused by the new method-preserving-redirect floor, and a well-known URL that redirects Basic-auth requests to a sibling host arrives unauthenticated under the cross-origin auth-header drop and fails. If LAN CalDAV is meant to work, that needs an explicit operator-consented admission, not a wider gate.
  • The _CREDENTIAL_FIELDS allowlist on PUT .../calendar/credentials refuses a direct access_token/refresh_token write; a user pasting a manually-minted token cannot connect except through the OAuth flow. Stated design, but it is a refusal of an input class with no verdict available.
  • The OAuth callback state gate and the symlink/junction guard. handle_oauth_callback refuses any absent/expired/forged state; credentials._ensure_home/_load_sync refuse a linked store directory, so an operator who manages crew-home subdirectories via symlinked dotfiles loses the credential store with only a log warning to explain it.

[SCOPE-REVIEWED] 3117c52

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • ubuntu-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • windows-latest (platform windows): 7 classified, 0 newly refused, 7 still allowed.

No candidate flipped from allowed to refused.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
kaizawa97 and others added 2 commits September 30, 2026 12:11
…osoft 365

Meetings had to be created by hand, so the app never knew what was already
scheduled. This adds calendar providers -- CalDAV, Google Calendar and
Microsoft 365 -- behind the existing `CalendarProvider` seam, plus the
credential store and OAuth handshake they need. Five providers ship:
`none`, `ics`, `caldav`, `google`, `microsoft`.

Credential store (`backend/credentials.py`)

Credentials live in a TOP-LEVEL leaf of the crew data home,
`<crew-home>/meetings-credentials/calendar-credentials.json`. Not under
`app_data_dir("meetings")`, which `store.contain` opens to agent-supplied
paths; and not under `workspace/`, because the OS sandbox mask binds only
over a directory that exists at spawn time and only a direct child of the
data home can be materialised before every spawn (a nested leaf's
agent-writable parent could also be renamed out from under the mask). The
directory is registered in all three places at once: `_CREW_SECRET_LEAVES`
(agent file tools), `sandbox._CREW_HIDDEN_LEAVES` (spawned commands, every
mode) and `sandbox._CREW_PRECREATE_HIDDEN_DIR_LEAVES` (created empty at 0700
before each namespace spawn). The DIRECTORY is fenced, not the file, so the
`atomic_write` temp sibling is covered too. A store an earlier build left at
`workspace/meetings/calendar-credentials.json` is moved (never copied) on
the first read that finds the new location empty; only a regular file is
moved (lstat), and a reader that loses the move race to a concurrent reader
still reads the relocated store.

The store is read-modify-write under one lock, written through
`atomic_write(restrict_to_owner=True)` fail-closed, and refuses writes
while the file is unreadable or schema-invalid (display degrades to "not
connected"; the malformed file stays for a human to salvage). The path is
module state, not a request parameter. `GET /calendar/credentials`
publishes field names and booleans only; `PUT` is an allow-list per
provider, so a client cannot hand the app an `access_token`.

Fetch safety (`fetch_vetted`)

All outbound HTTP -- the `.ics` fetch, the CalDAV REPORT, both cloud APIs
and the OAuth token POST -- goes through one module-level gated fetch:
`link_unfurl.vet_unfurl_url` vets the address, DNS is pinned per hop,
redirects are followed manually so every hop is vetted, the body is
size-capped while streaming. `auth_headers` are dropped across a
cross-origin redirect, and a non-GET follows only the method-preserving
307/308. https-only implies port 443 at the vet boundary.

OAuth (`backend/oauth.py`)

Authorization-code + PKCE (S256), run by the gateway's app backend rather
than through kiro-cli's connections because the token is consumed by the
gateway itself (the calendar poller syncs with no agent session). Pending
flows live in memory with a TTL; `state` is compared in constant time and
the flow is consumed before the exchange; access tokens refresh early. The
token POST accepts HTTP 400 so an RFC 6749 error body (`invalid_grant`) is
read and its description surfaced. Every callback exit, including a forged
or expired `state`, writes a `meetings.calendar_oauth_callback` audit
record. The redirect URI derives from the request's own origin.

Events

Every provider funnels through `build_event`, which redacts displayed
fields once and derives `event_id` from the ORIGINAL uid; a uid the
redactor flags as credential-shaped switches to a digest-only id.
Google's date-only start and Graph's `isAllDay` set `all_day`. Graph
responses that ignore the UTC `Prefer` header are mapped through
`_WINDOWS_TO_IANA` before the UTC fallback. CalDAV Multi-Status is parsed
with `defusedxml` (`forbid_dtd=True`).

Two ratchets re-pinned for the new leaf, each with its reason recorded at
the pin: `test_security_gate_liveness._PACKAGE_LINE_BUDGET` (the fence
declaration and its comment in `paths.py`) and
`test_sandbox_protected_name_holds.EXPECTED` (a root leaf is held by its
own name only, three launcher entries per tier, like `auth-store-staging`).

Specs updated: `docs/system-specs/modules/meetings.md` (routes, provider
table, credential store, OAuth custody decision) and `security.md`
(keystone directory `meetings-credentials`).

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
The calendar providers that need a credential (CalDAV, Google Calendar,
Microsoft 365) could only be connected by calling the credentials and
OAuth routes by hand: Settings -> Calendar showed a provider picker and a
source field and nothing else.

Settings -> Calendar now renders the credential form for the active
provider under the picker. The form's shape comes from the backend: GET
/calendar/credentials gains a `providers` map built from the same
allowlist and OAuth table the PUT enforces, so the fields shown are the
fields that can be written and a provider that takes none renders
nothing. Every field is write-only (a stored value never reaches the
browser): a set field shows a mask with Replace / Remove, a typed value
is sent as a string, a removed one as null, an untouched one not at all.

The status badge is derived from field names, and only an OAuth provider
is ever called Connected: its refresh token exists because a sign-in
against the real tenant succeeded. A password provider with every field
stored reads "Credentials saved", because nothing in the form verified
the password. The status re-reads on window focus, because the OAuth
consent finishes in another tab. The OAuth client fields link to the
provider's console, where a client id comes from.

Sign-in stays disabled until a client id is stored; it opens the consent
URL in a new tab. `window.open` with `noopener` answers null whether or
not a tab opened, so a blocked popup cannot be detected: the same URL is
always offered as a link and the toast is worded for both outcomes.
Disconnect sits on the status row beside the badge, so the action row
stays at Save + Sign in. Failures render in-page through ErrorNotice: a
status load that failed with no form on screen carries the agent
hand-off; a failure beside typed-but-unsaved credential values does not.

The OAuth callback, GET /api/apps/meetings/calendar/oauth/callback, is
exempt from the dashboard token gate (GET only, on the method-scoped
bypass map beside the self-authenticating webhooks). From the Electron
shell the consent runs in the OS browser, which holds no dashboard
cookie, so on the ordinary gate every desktop sign-in lands on a 403
JSON page and no token is stored. The handler's single-use `state` is
its admission; a test pins the exemption to that one path and method and
to the route the app registers.

Strings land in all twelve locales; the pseudolocale is regenerated.

Stacked on kirodotdev#2190; rebase onto main once kirodotdev#2190 lands.

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-settings-ui branch from 33ed7af to 3117c52 Compare September 30, 2026 12:19
@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Unverified any-port loopback claim span=4d2afcdbc2de

needs-a-decision.
The sentence lives in #2190's routes/calendar.py and matches both providers' documented behaviour for desktop / public clients, but no live tenant has confirmed it with the derived URI.
Maintainer: accept the documented behaviour, or hold merge for one live Google and one Microsoft 365 consent?

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Partial and saved badges read the same span=643eed0b7283

fixed in 3117c52.
A partially configured provider now reads "Not connected" with the warning badge; "Credentials saved" appears only when every field is stored. Tests cover a removed field and a pre-consent OAuth provider.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Missing rendered evidence for the credentials UI span=e160f4a06c73

needs-a-decision.
Not closed by this push: Settings -> Calendar (CalDAV not connected / saved / partial, Google before and after a client id) still needs current-head screenshots in the description.
They will be captured from an isolated gateway and attached; until then this blocker stands.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • OAuth consent never completed live span=86276a7d94d0

needs-a-decision.
Boundary tests cover the callback admission and the https-preserving redirect URI, but they cannot prove a provider-console registration or a consent from the desktop shell.
Maintainer: should merge wait for one manual consent run against a registered client from the desktop app?

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Unbounded legacy credential file can exhaust memory span=93ccc502637d

fixed in 3117c52.
Fixed in #2190's 8dc1f9fe80, which this PR is restacked on: the legacy-location read is removed entirely, so no unbounded legacy file is ever opened.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Callback URI is http behind TLS termination span=d1f05980ce55

fixed in 3117c52.
Fixed in #2190's 8dc1f9fe80: _redirect_uri uses dashboard.origin.is_https_request (loopback-peer X-Forwarded-Proto only) to keep the browser-facing https scheme.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 30, 2026

Copy link
Copy Markdown
Contributor

Open PR triage (2026-10-05): REBASE after #2190, merge discussion on the stack

This is a code-level audit of head 3117c529d1 against origin/main a97659dfc3. I read the full merge-base diff and the current main code, not only the description.

Stack, confirmed from git. origin/pr/8081 is #2190's head 8dc1f9fe80 plus one commit, 3117c529d1 (24 files: token_auth.py, routes/calendar.py credential_schema(), CalendarCredentials.tsx, SettingsView.tsx, api.ts, i18n, tests). That makes this PR OVERLAPPING with #2190 (open PR), not a duplicate: it holds all of #2190 as the base half of the stack and adds the Settings UI on top.

Stale. The merge base f10a74d412 (#15203) is 732 commits behind main. git merge-tree reports content conflicts in 5 files, and every one comes from #2190's half: security/paths.py, docs/system-specs/modules/security.md, test_meetings_owner_gate.py, test_sandbox_protected_name_holds.py and test_security_gate_liveness.py. This PR's own commit merges cleanly. _BYPASS_EXACT_METHODS and API_BASE = /api/apps/meetings are unchanged on main.

Nothing on main covers this. Main still has only the none and ics calendar providers. It has no credentials.py, oauth.py or credential/OAuth routes, and no credentials UI. #8080 (merged PR) added the poller only. #7194 (notes) and #15720 (remote-crew relay) touch the same files only through additive hunks.

The 2026-09-25 request-changes review is addressed on this head. That review was against c53d1a25. The store now sits at the top-level meetings-credentials/ leaf, which is listed in _CREW_SECRET_LEAVES, sandbox._CREW_HIDDEN_LEAVES and _CREW_PRECREATE_HIDDEN_DIR_LEAVES. @bolichen97, please re-check it and dismiss the review if you agree.

Still open (already raised, so this is a note, not a new request-changes):

  • GPT BLOCK: credentials.write_for (credentials.py ~L357-362) still merges a new client_id and keeps the old access_token/refresh_token. This PR's form makes client_id editable, and credentialBadge() keeps reporting Connected because a refresh_token exists, even though the next refresh will fail.
  • Opus advisory: _StoreUnreadable is caught at none of the route boundaries.
  • Design and UX BLOCK: no screenshots. First-principles: no live Google/M365 consent has been run.

No breaking change or P0 in this commit. The GET-only bypass for /api/apps/meetings/calendar/oauth/callback is additive. The handler admits a request only when state matches a single-use, TTL-bound value (compare_digest), and /calendar/oauth/start stays both token-gated and owner-gated.

Recommendation: land #2190 first, or deliberately collapse the two PRs into one. Then rebase this PR and re-measure the ratchet tests. Do not close either PR on its own.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for the thorough work on the calendar providers and the Settings flow. We are closing #2190 and #8081 together: both branches are about 5,500 commits behind main and conflict, #8081 has an open security review (the Linux sandbox does not mask workspace/meetings for already-running namespaces), and #2190 still has open review blocks. Main now ships the .ics provider plus the calendar poller (#8080), and Google Calendar and Microsoft 365 can both publish an .ics feed, so the basic need is covered. Richer provider support is tracked in #6769 (first-party Google Workspace connectors) and #16228 (multiple calendar sources). A fresh, smaller PR on current main is welcome.

The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up.

@iamwhatever iamwhatever closed this Nov 1, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants