Repository navigation
feat(credential-groups): workflow connect links, connection status and requests - #10743
Conversation
…ions header cleanup
- People: one status badge per person (Revoked > Email failed > Needs reconnect >
Connected > Expired > Invited); needs-reconnect connections shown distinctly
instead of being filtered out
- Row menu: Resend -> Send reminder, hidden once the enrollment is completed
- Remove uncalled props (searchConnection, panel, filters, setupFallback,
requestDisabled, enabled, visibleProviders) and the 'Revoke all account access' variant
- Integrations: drop the persistent help text; 'Update configurations' becomes a
header overflow 'Re-apply app configuration' with a confirm modal; provider ->
integration in catalog and toast/remove copy
- Invitation email: org groups read '{Org}', not '{Org} workspace' (explicit ownerKind)
- README: current tab and action names
…link errors, connect sign-in - lib/credential-groups/return-url: closed allowlist (slack.com/app_redirect, *.slack.com, slack://app|open|channel) matched on the raw string before parsing - OAuth attempt state carries a validated returnUrl and a 'connect' returnTo; the callback reads the destination only from stored state; enroll and completion pages render a 'Return to Slack' link (never an automatic redirect) - explainCredentialGroupEnrollmentLink: expired / revoked / paused / delivery failed / wrong account outcomes for a signed-in person; others see only a masked address - login: credential-group callbacks get 'Sign in to connect your accounts' with social first
Invitation bearer tokens move to a new credential_group_enrollment_link table (migration 0489, expand-only, backfilled one 'email' link per existing enrollment). Issuing a link (admin invite, resend, self or viewer enroll) inserts a link and never invalidates another, so an emailed link keeps working after the person connects themselves, and an OAuth attempt started before a resend still completes. - Every token check (public resolve, bind, completion, OAuth and MCP grant persistence) goes through liveEnrollmentLinkCondition: an unrevoked link, unexpired only while the enrollment has no bound user. A hash with no link row falls back to the legacy column the released app still writes during the deploy window. - invitation_token_hash stays NOT NULL and mirrors the newest link so a rollback keeps working; invitation_expires_at keeps the latest expiry. - Self/viewer enroll no longer resets createdBy, invitedAt, sentAt or status on an existing enrollment; admin invite and resend keep their behavior, and resend's sentAt write is guarded by its own link. - Disconnect and revoke revoke every link; a reinvitation after revocation issues a fresh link without reviving the old ones. - delivery_failed no longer blocks a session-verified or bound person holding a live link (completion, MCP grants, personal tokens).
- Credential block: get_connection_status (collapsed connected / not_connected /
needs_reconnect + credentialId + stable connectUrl) and request_connection
(constant { requested, connectUrl } result).
- Shared connect URL builder lib/credential-groups/connect-url.ts.
- Org admin policy for workflow connection requests, stored as a
WorkflowConnectionRequests statement in the organization account access policy
(v2 documents without it still parse; absent = off). Access updates preserve it.
Read/update org operations, route, contract, React Query hook, and an Access tab
section.
- requestOrganizationAccountConnection: policy-gated (enabled, workspace, email
domain, provider), daily cap under a group lock, per-email invitation lock,
creates only absent enrollments (never reactivates revoked or re-attributes an
admin invite), optional email with the connect link, audited with the workflow
as actor.
- Expand-only migration: nullable credential_group_enrollment.requested_by_workflow_id.
- Real-Postgres integration tests for status mapping and request guards; codec tests.
- /credential-groups/<publicId>/connect resolves the signed-in, verified person's own enrollment (resolveCredentialGroupConnectTarget, session operation credential_groups.connect.resolve) and mints a one-hour 'connect' link focused on the single matching option, then hands off to the enroll page. Outcomes: ready, wrong_account, not_invited, revoked, choose_option, unavailable (unknown ID, disabled group, entitlement off and unoffered provider answer identically). Organization members with no enrollment go through member self-enroll. `provider` is the credential provider ID; `return=slack` opens slack://open, other values must pass the Slack allowlist. The session is the authority, so an unbound enrollment whose invitation expired (or that a workflow requested with no link) still connects. Per-IP and per-user rate limits. - Focused links are enforced server-side: OAuth start/complete for another option and MCP start/complete are refused (CredentialGroupLinkFocusError, redirected with oauth=other_option), and the enroll page shows only the focused option with no Submit. - A connection saved through a focused link completes the enrollment and fires form_submitted once, through the same path as Submit. - findCredentialGroupEnrollmentLinkRecord resolves through the link table (legacy column fallback as liveEnrollmentLinkCondition), so revoked and expired links are explained; a link revoked by a disconnect on a live enrollment reads "Link no longer active". - lib/credential-groups/connect-url.ts (shared with W3), publicId in the org accounts response, and a "Copy connect link" menu on the People tab. - Unavailable / wrong-account states lifted into app/credential-groups/link-states.tsx.
- Request policy moves to its own table (credential_group_connection_request_policy, own revision; no row = off). The Access resource-policy document, its codec, the DB validator, and the Access save path are back to staging byte for byte, so old pods and rollbacks keep reading every Access document. The connections.request evaluator action is gone. - Turning requests off skips workspace/integration cross-checks and prunes stale ids; reads prune them too. Policy lists normalize on parse (no separate sorted refine); oversized lists are validation errors. - Request log table (credential_group_connection_request): every accepted request, whatever the person's state, is logged and counts toward the daily cap, which is checked before any per-address lookup and fails identically for every target. - Emails go through the outbox (enqueued in the request transaction, delivered detached right away, retried by the worker), so the response never waits on rendering or sending. The handler re-reads the enrollment and sends nothing to a revoked or bound person; success clears lastDeliveryError. - Reminders: only for workflow-created, unbound, invited enrollments, when no request for the address was logged in the last day, at most 3, none after 30 days; the claim is a conditional UPDATE so a racing revoke sends nothing. - request_connection refuses + aliases. Invitation email names the requesting workflow (from the workflow record) and the organization. - Block drops the redundant provider output; docs updated. connect-url.ts matches the shared builder. requireCurrentWorkflow exported instead of a wrapper. - Admin UI: "Connection requests from workflows", summary with workspaces and email state, exact-domain and daily-limit hints, inline free-mail domain warning. - Integration tests: stale-policy disable, cap counts existing addresses, identical cap error, plus-alias refusal, reminder cap and 30-day stop, revoke race, Access and request policy saves independent.
- Reinviting an enrollment the released app revoked (status only) now revokes
every link into it first, so old emailed/self links cannot come back to life.
- A legacy-column invitation with no link row (emailed by the released app
during a deploy) is adopted as an 'email' link before the column is
overwritten.
- Delivery bookkeeping is guarded on invitedAt as well, so a slower, older send
can no longer record delivery_failed (or sentAt) over a newer send.
- 'self' and 'connect' links always expire after one hour; only an emailed
link outlives its expiry once the enrollment is bound. The link outcome
explains an expired connect link accordingly. invitation_expires_at (the
admin-visible expiry) now tracks the newest emailed link only.
- Removed the session-less bearer completeCredentialGroupEnrollment and
getPublicCredentialGroupEnrollment (no production callers), their tests and
mocks, plus a mock-asserting and a constant-restating test assertion.
- The completion page no longer reads ?return=: a Slack destination is stored
server-side bound to the signed-in user (completion-return) and only its
opaque returnId travels in the redirect, from both the OAuth callback and the
Submit path. On failure it offers Open Sim and Return to Slack.
- Return allowlist narrowed to slack.com/app_redirect (app/team/channel only),
slack://open, and slack://app?team=T…&id=A….
- The OAuth start route no longer validates the return URL itself; the use
case and attempt state do. An overlong return (up to 8192) is ignored, not a
400.
- Copy: revoked shows the title only, needs-new-link asks "an admin at {Org}
for a new link", completion copy uses "accounts".
- Login recognizes absolute same-origin /credential-groups/ callbacks and shows
the divider in connect mode whenever another method follows social sign-in.
- Connect page: an org member with no enrollment is enrolled only by a confirmation POST (/api/credential-groups/connect/[publicId]), never on GET, and only after the member self-enroll checks (integrations.manage permission group, finished setup); refusals read not_invited. A revocation racing self-enrollment reads revoked, other refusals unavailable; no second bind after self-enroll. - Focused links refuse Submit (/complete); the MCP start route keeps returnTo/return on every redirect back. Copy: stable-link unavailable message, masked email on wrong_account, "You can close this tab." beside Return to Slack. - Enrollments created without an emailed link (self-enroll, workflow request, disconnect) store an unissued placeholder in the legacy token column that no token hashes to, so link adoption skips it and pruning a session link cannot revive its token through the column. - Retention: the outbox processor prunes connection request rows after two days and self/connect links a day past expiry, in bounded batches, with indexes for both. - 0490 is replay-safe; connect URLs and the enroll handoff come from connect-url.ts. - Fix a TDZ read of `focused` in the enroll page's error handler.
- Integrations rows get Copy connect link; People drops the floating menu
- People: Send reminder hidden only when connected or revoked, no menu on
revoked rows, gray account chips, Loading… and request-led empty state
- Workflow connection requests: clearer labels, All workspaces, free-mail
warning through the field hint
- Connect page: Connect your {Integration} account with a centered button,
shorter not-invited copy, Return to Slack on dead ends (also on enroll)
- Completion: Try again after a failed Integrations connection, Slack
secondary on failure, failure-aware page title, Slack continue copy
- Sign-in title, invitation email footer for workflow requests
- Credential block: Integration labels, person@example.com placeholder,
Request Connection guidance; docs follow
…low out of enrollments - links.ts holds link storage: liveness condition (now an indexed primary-key lookup instead of an EXISTS-or-legacy filter that scanned every enrollment), its TypeScript expiry rule, link insertion shared by emailed, self and connect links, legacy adoption, the link record reader, and the focus error with a code-based predicate the routes use. - connect-subject.ts loads the connect target and mints the connect link, self-enrolling and binding in the same locked transaction. - The connect page resolves read-only, then a separate start operation writes and audits; a revocation racing it reports revoked, an unfinished setup reports unavailable. - Explaining a failed link is a defined use case; an expired connect link offers Start again, and a failed delivery is no longer an outcome. - The confirmation POST requires a same-origin request and has its own rate-limit bucket. - An admin reinvitation clears a workflow's request marker and reminder count. - Workflow connection lookups read the policy and public ID from the resolved context and refuse through one pure policy check. - Completion redirects take an options object; one DAY_MS and invitation lifetime. - README and 0489 record link lifetimes, revocation semantics during deploy, and the contract phase for the legacy invitation column.
The connection-request log and expired session links are pruned by an hourly cleanup-credential-group-links job (background task, cron route, Helm, Compose crontab and self-hosting docs), following cleanup-oauth-tokens, instead of from the outbox processor, whose changes are reverted.
…eturn for workflows - The email subject names only the organization and integration; the body shows the workflow name with control and formatting characters removed, cut to 60 characters. - The email handler skips an enrollment an admin has since reinvited, records a failed delivery as delivery_failed like an admin invitation, writes only while the enrollment is as the request left it, and never throws after the provider accepted the email, so it is not sent twice. - The Credential block's connection operations take a Return to input (none or Slack) that the connect URL carries as return=slack. - Saving the request policy uses the contract-parsed policy instead of parsing it again.
Reconciliation after the core and UI lanes merged:
- One helper in return-url.ts turns a stable connect URL's `return` value into a destination:
only the keyword `slack` (the Slack app), shared by the connect page and the connect use case;
the enroll page keeps accepting the validated URL the server put on its link.
- A workflow's repeat request emails with a "Reminder: ..." subject (organization and integration
only). The inbox preview no longer shows the workflow name, which appears only in the body.
- The Credential block's Return to options read None / Slack; the block docs describe the input.
- The organization-accounts query mock covers the personal-accounts and request-policy hooks.
- Fix the enroll page's duplicated slackReturnUrl prop left by the merge.
- Request Connection's use case returns only { requested, connectUrl }; the enrollment and
whether it was created stay inside the module for the audit row.
Tests (each shown red against a reverted guard):
- 0489 backfill: legacy invitations become one emailed link each, a replay adds nothing, and
every token answers as it did through the legacy column.
- Connect POST: IP limit, signed-out/unverified, per-person limit, non-ready outcomes, no-store
and no-referrer on success, no GET handler.
- Request Connection answers revoked, admin-invited and new people identically; the limit test
seeds a real revoked enrollment; the one-day window; concurrent repeats send one reminder.
- Admin request policy refuses a member, another organization's admin, and a stale revision.
- Focused links refuse MCP completion and always read their one option; MCP grants refuse
revoked and expired links at real Postgres; racing saves complete the enrollment once.
- A revocation holding the lifecycle lock wins over a waiting completion; a bounced invitation
still binds its person, a status-revoked one does not.
- Retention keeps rows exactly at the cutoff, skips locked rows, and caps batches per run.
- Lock-wait helpers wait on the specific holder (pg_blocking_pids), not any lock in the server.
- Removed call-order and mock-argument unit tests now covered at the real boundary.
Connect page runs only the start use case (drops the read-only resolve twin), shared helpers for unissued enrollments, revocation, pending workflow requests and no-store redirects, strict same-origin check moved to lib/core/security, lib throws OrchestrationError directly, cleanup job on the cleanup pool, admin modal validates with the policy schema, duplicate error surfaces removed, comment fixes.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
1 issue found across 104 files
Confidence score: 4/5
- In
organization-connection-requests.tsx, Save can be disabled without showing which field needs attention, leaving users unsure how to proceed. Surface the schema validation message on the affected field.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/ee/credential-groups/components/organization-connection-requests.tsx">
<violation number="1" location="apps/sim/ee/credential-groups/components/organization-connection-requests.tsx:297">
P3: Save is disabled for invalid domains, missing integrations, or an empty workspace selection, and nothing on screen says why. Surface the schema's validation message on the affected field, as the daily-limit field already does.</violation>
</file>
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
…cy UX, docs
- Connect page: presentational states in link-states (ConnectConfirm, DifferentEmail,
NotInvited with Switch account, RequestExpired, VerifyEmail, ChooseConnectOption) and a
shared action row that pairs Return to Slack with "You can close this tab."
- Enroll page: a focused connect link opened by someone already connected shows
"{Integration} connected"; Slack returns use the shared action row
- People: Invited/Requested/Expired/Email failed/Not connected/Connected/Needs reconnect/
Revoked, Requested by workflow marker, reminder while any active option lacks a
connection, Re-invite on revoked rows
- Workflow requests policy: close modal and toast on revision conflict, header switch
opens the editor when the saved policy cannot be enabled, Not in effect badge, inline
domain errors, labelled toggle, loading skeleton, All allowed workspaces
- Contracts: requestedByWorkflow/emailed on People rows, inEffect on the policy read
- Docs: when Sim emails, lower-cased event email, listen for added and reconnected,
member-only status links, Find returns the first match, editor runs are real,
policy is the only request gate, Return to Slack opens the app
… request lifecycle - liveEnrollmentLinkCondition refuses a revoked enrollment itself; caller copies removed - unexpiredLinkCondition is the single expiry rule for lookups, link explanations and retention; a bound person's emailed link stops expiring only while the legacy column names it, so the pre-link app's disconnect ends it - enrollment-lifecycle holds the pure row rules (unissued values, revoked, request expiry); findOrCreateUnissuedEnrollment is the one locked find-or-create for link-less enrollments - an unbound enrollment is a request that expires at invitation_expires_at; People's expired flag uses the same predicate - email verification that a deployment cannot enforce counts as verified for enrollments - retention drains are isolated from each other's failures - 0490 adds requested_provider_id and puts the enrollment columns first
…return destination
- openCredentialGroupConnect (GET page) only reads; startCredentialGroupConnect (same-origin
POST) enrolls or binds and mints the focused link in one transaction, then goes straight to
the provider's OAuth start; refusals, limits and outages return to the page, never JSON
- outcomes: ready_to_connect, confirm_self_enrollment, wrong_account, different_email,
not_invited, expired, revoked, choose_option, unavailable, verify_email
- connect URLs built for one person carry a for= request handle (keyed hash of group and
email); a mismatch says so without revealing the address and never self-enrolls
- page and POST share one session gate; a limiter outage is told apart from a real limit
- ConnectReturnDestination ('slack') travels block input, return=slack, OAuth attempt and
completion redirect, resolved to slack://open only where rendered; the Redis completion
return store and URL allowlist are gone; the in-app return enum is renamed origin
- OAuth attempts live 30 minutes (state v6, MCP v5); an expired attempt still offers the way
back to Slack
- signed-in OAuth starts are bounded by their enrollment, not the shared IP bucket
- a focused connection completes the enrollment only when every active option is connected
or a workflow requested it
- reconnecting the wrong account tells an invitee which account to choose
…ct, and block copy - the daily cap counts distinct addresses; asking again today is unlogged and uncapped - a workflow request, its reminder, and an admin reminder renew an unanswered request - an admin's Send reminder on a workflow's open request re-sends that workflow's request for its integration and keeps the attribution - request emails use the outbox's default attempts and record sentAt only on delivery - the policy read reports inEffect; saving rejects an integration no chosen workspace may use; conflict copy and a wider free-mail list - org invitations no longer name the group; the workflow email asks the person to sign in or create a Sim account with their address - the block input is returnTo; the dropdown hides ORGANIZATION_OPERATIONS from the block; handler copy says Integration and asks for the primary email
…nect page - an organization member who passes the self-enroll checks (membership, Integrations capability, setup) and whose own unbound request expired is offered the confirm step instead of the expired dead end; non-members still see expired - the start POST renews that enrollment (invitation_expires_at) and binds it in the same transaction that mints the focused link, instead of creating another enrollment - a request-handle mismatch is still refused first and never renews
…token authority The 0490 backfill still turns each existing invitation_token_hash into one emailed link. After that, nothing reads or writes the enrollment column: - drop the legacy-column branch of liveEnrollmentLinkCondition, the token lookup fallback, and adoptLegacyInvitationLink - stop mirroring the newest emailed link into the column; a bound person's emailed links simply do not expire (self and connect links always do) - drop the unissued: placeholder helpers and the cleanup job's column check - revoked is status === 'revoked' alone; a reinvitation no longer re-revokes links a revocation already revoked - 0490 makes invitation_token_hash nullable; schema.ts marks it unused and scheduled for removal by its own contract migration - remove tests of old-app behavior; fixtures seed link rows instead of the column; README states current behavior only
…st cap - Refuse every workflow connection request once the daily cap is reached, repeats included, so the cap reveals nothing about other workspaces. - Re-check membership, Integrations capability and setup inside the link transaction for self-enrollment and expired-request renewal. - Spend the per-person connect budget only on the Connect POST; the page keeps its per-IP limit. - Send malformed and cross-origin Connect POSTs back to the connect page (unavailable / try again) instead of JSON. - Add an already_connected outcome to the connect page so a connected person is not sent through consent again; needs-reauth still connects. - People: expose `bound` (drop `emailed`, derived from sentAt), rework the status order, label "Send email" before any email, surface per-email re-invite failures; policy row explains "Not in effect" and Save shows why it is disabled. - Connect/enroll/complete pages: recovery stays primary beside Return to Slack, "You can close this tab." only once connected, no Open Sim on a focused connect link, Slack return kept on early states, clearer expired copy; one slackHref vocabulary. - Block and refusal copy name the integration; scripts stop writing invitation_token_hash; docs and README match.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 134 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
…chart for the cleanup cron
- Dry run: answer a Credential block's request_connection whole, like other blocks that write outside the tool seam, so no enrollment or email is made. - A workflow's open request records the latest workflow and integration together, so a reminder names the workflow that asked for it. - A focused connection finishes a workflow's request only when the requested integration is connected (or every option is). - Connect page: unknown, disabled and unoffered groups answer unavailable before the verify-email step. - Explain answers unknown to a viewer whose email is unverified. - Connect link refusals roll back, so a refused self-enrollment leaves no row. - Policy editor opened from the switch saves the policy enabled. - Request log and session link retention share an inclusive cutoff. - Workflow names collapse whitespace before control characters are removed; invitation email says the 7 days apply before the person accepts. - Integration tests: release held locks in finally, assert in_progress, and clean up the delivery suite's outbox events.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 141 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
/credential-groups/<publicId>/connect?provider=…&return=slack) that signs the person in, verifies it's them, and connects exactly the integration asked for, then offers "Return to Slack"credential_group_enrollment_link: issuing a link (invite, resend, self-connect) no longer kills other live links; emailed links stop expiring once the person is bound; self/connect links are short-lived and focused on one option; disconnect/revoke revoke every linkGet Connection Status(collapsedconnected | not_connected | needs_reconnect+connectUrl) andRequest Connectionoperations, plus a "Return to" inputRequest Connectiononly works under an org-admin policy (off by default): allowed workspaces, exact email domains, integrations, daily cap, optional email. Authority comes from the policy inside the use case, not role checks. Every per-person state returns the same result, daily cap counts distinct people, reminders are capped, email goes through the outbox and is marked sent only on deliveryreturnTo=slackkeyword resolved toslack://openwhere renderedcleanup-credential-group-linkscron prunes expired self/connect links and the request logType of Change
Testing
check:migrations,bun run generate(no drift), block registry check, targeted audits (api-validation:strict, boundaries, client-boundary, comment-hygiene, test-patterns, file-names, utils, explicit-any, source-conventions, permission-group-enforcement, schema-mock, cron-parity)Checklist
test-auditauthoring gate)