Skip to content

feat(credentials): add managed credential groups - #6697

Open
TheodoreSpeaks wants to merge 12 commits into
stagingfrom
feat/slack-user-oauth
Open

feat(credentials): add managed credential groups#6697
TheodoreSpeaks wants to merge 12 commits into
stagingfrom
feat/slack-user-oauth

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • add enterprise Credential Groups settings, email enrollment, and managed credential storage
  • support Gmail, Google Calendar, and Slack custom-app OAuth through provider adapters
  • add a Credential Groups workflow block for listing credentials and people, sending invites, and listing groups
  • keep managed credentials hidden from Connected Accounts while allowing fail-closed credential ID execution

Type of Change

  • Feature

Testing

  • 264 targeted tests
  • bun run lint:check
  • bun run check:audits
  • bunx turbo run type-check --filter=sim --filter=@sim/auth
  • bun run check:migrations origin/staging

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 14, 2026 7:42pm

Request Review

@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Large surface area across OAuth token issuance, public enrollment, and credential hiding; misconfiguration could leak managed tokens or expose credentials through the wrong API path.

Overview
Introduces enterprise Credential Groups: workspace admins can define collections (Gmail, Calendar, Slack custom app), invite people by email, and collect OAuth via tokenized public enrollment routes with IP/OAuth rate limits and provider callbacks. Workspace settings UI, invitation email, and a Credential Groups workflow block support listing credentials/people/groups and sending invites under executor delegation.

Managed OAuth credentials (managed_oauth) are stored for enrollments but are excluded from Connected Accounts listings, memberships, drafts, and member APIs; the OAuth token route adds a dedicated path that requires workflow delegation, a tool ID, and tool-trusted scopes before issuing tokens (ordinary credentials ignore stray delegation headers).

Documents CREDENTIAL_GROUPS in .env.example and gates the settings nav, block visibility, and uploads for enrollment principals.

Reviewed by Cursor Bugbot for commit 8253b2d. Bugbot is set up for automated code reviews on this repo. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds enterprise-managed credential groups, public enrollment and custom-app OAuth flows, delegated managed-credential execution, administrative settings, and the supporting database schema.

  • Adds credential-group creation, enrollment, revocation, resend, completion, and Slack managed-user flows.
  • Adds provider adapters and delegated token resolution for Gmail, Google Calendar, and Slack.
  • Adds a workflow block and executor handler for credential-group operations.
  • Hides managed credentials from ordinary Connected Accounts APIs while requiring scoped workflow delegation for execution.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/credential-groups/enrollments.ts Implements invitation, resend, revocation, and completion lifecycles with shared locking and transactional revalidation; the previously reported races are addressed.
apps/sim/lib/credential-groups/oauth.ts Persists OAuth grants under lifecycle and group locks while rejecting revoked enrollments, validating current policy, and preserving completed reconnect state.
apps/sim/app/api/auth/oauth/token/route.ts Adds a fail-closed managed OAuth path requiring a credential-scoped workflow delegation and trusted tool scope policy.
apps/sim/lib/credentials/managed-oauth.ts Adds managed credential token storage, status handling, refresh, and provider-policy validation.
packages/db/schema.ts Adds the credential-group, enrollment, option, managed-credential, and supporting relational schema.
packages/db/migrations/0291_fuzzy_wong.sql Introduces the database objects and constraints required by managed credential groups.
apps/sim/executor/handlers/credential-group/credential-group-handler.ts Adds executor support for credential-group listing, people, invitations, and credential operations.

Sequence Diagram

sequenceDiagram
  participant Admin
  participant API as Credential Group API
  participant DB as Postgres
  participant Recipient
  participant OAuth as Provider OAuth
  participant Exec as Workflow Executor
  Admin->>API: Create group and send invitation
  API->>DB: Persist group, options, and enrollment
  API-->>Recipient: Enrollment link
  Recipient->>API: Open enrollment and start OAuth
  API->>OAuth: Authorize configured provider
  OAuth-->>API: Callback grant
  API->>DB: Lock lifecycle and persist managed credential
  Recipient->>API: Complete enrollment
  API->>DB: Lock and validate current policy/readiness
  Exec->>API: Request token with scoped delegation
  API->>DB: Authorize and resolve managed credential
  API-->>Exec: Access token
Loading

Reviews (13): Last reviewed commit: "fix(credentials): redirect unavailable o..." | Re-trigger Greptile

Comment thread apps/sim/lib/credential-groups/oauth.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/api/auth/oauth/token/route.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/credential-groups/enrollments.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit caad5d0. Configure here.

Comment thread apps/sim/lib/credential-groups/enrollments.ts Fixed
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4a2a6e7. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/credential-groups/enrollments.ts Outdated
Comment thread apps/sim/lib/credential-groups/enrollments.ts Outdated
Comment thread apps/sim/lib/credential-groups/enrollments.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

Comment thread apps/sim/lib/credential-groups/oauth.ts
Comment thread apps/sim/ee/credential-groups/components/credential-group-detail.tsx Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 063ff6e. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

Comment thread apps/sim/app/api/credential-groups/enroll/[token]/oauth/[optionId]/route.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile-apps

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8253b2d. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants