stack icon indicating copy to clipboard operation
stack copied to clipboard

Feature: Netsuite oauth provider

Open sicarius97 opened this issue 4 months ago โ€ข 3 comments

Adds a new custom oauth provider for netsuite


[!IMPORTANT] Introduces NetSuite as a new OAuth provider, updating relevant schemas and configurations to support it.

  • Behavior:
    • Adds NetSuiteProvider class in netsuite.tsx to handle OAuth with NetSuite, including token fetching and user info processing.
    • Updates getProvider() in index.tsx to support netsuite as a provider type.
    • Adds netsuiteAccountId handling in createOrUpdateProjectWithLegacyConfig() in projects.tsx.
  • Schemas:
    • Adds netsuiteAccountId to environmentConfigSchema in schema.ts.
    • Updates oauthProviderReadSchema and oauthProviderWriteSchema in projects.ts to include netsuite_account_id.
    • Adds oauthNetSuiteAccountIdSchema in schema-fields.ts.
  • Misc:
    • Adds netsuite to standardProviders in oauth.tsx.

This description was created by Ellipsis for 47025b53143775b5cd620bf2f7206e536afbdeb6. You can customize this summary. It will automatically update as commits are pushed.

Review by RecurseML

๐Ÿ” Review performed on 5da45d8..47025b5

Severity Location Issue Action
Medium packages/stack-shared/src/config/schema.ts:205 Naming inconsistency between schema property and API interface Dismiss
Medium packages/stack-shared/src/interface/crud/projects.ts:25 Object property using snake_case instead of camelCase in TypeScript code Dismiss
โœ… Files analyzed, no issues (3)

โ€ข apps/backend/src/oauth/providers/netsuite.tsx โ€ข apps/backend/src/oauth/index.tsx โ€ข apps/backend/src/lib/projects.tsx

โญ๏ธ Files skipped (trigger manually) (2)
Locations Trigger Analysis
packages/stack-shared/src/schema-fields.ts Analyze
packages/stack-shared/src/utils/oauth.tsx Analyze

Need help? Join our Discord

Summary by CodeRabbit

  • New Features

    • NetSuite added as a supported OAuth provider for sign-in, including token validation and user profile retrieval.
    • Dashboard: NetSuite provider option with an "Account ID" field and NetSuite branding (icon, title, color).
  • Chores

    • NetSuite added to the standard provider list.
    • Configuration schemas, interfaces, and defaults updated to accept and validate a NetSuite Account ID.
  • Tests

    • Updated tests to include NetSuite in allowed OAuth provider types.

sicarius97 avatar Sep 11 '25 14:09 sicarius97

@sicarius97 is attempting to deploy a commit to the Stack Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 11 '25 14:09 vercel[bot]

[!NOTE]

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds NetSuite OAuth support across backend, shared schemas/types, dashboard UI, branding, and templates: new NetSuiteProvider, registration and payload wiring (netsuiteAccountId), schema and CRUD additions, UI form field and icon/color assets.

Changes

Cohort / File(s) Summary
NetSuite OAuth provider implementation
apps/backend/src/oauth/providers/netsuite.tsx
New NetSuiteProvider extending OAuthBaseProvider with create, postProcessUserInfo, and checkAccessTokenValidity; configures NetSuite endpoints/scopes, reads accountId from options or env, normalizes userinfo, and validates tokens.
Backend registration & project wiring
apps/backend/src/oauth/index.tsx, apps/backend/src/lib/projects.tsx
Registers "netsuite" in provider map; includes netsuiteAccountId in payload for standard provider creation; maps environment auth.oauth.providers.netsuiteAccountId to netsuite_account_id in project create/update.
Shared schemas, types & utils
packages/stack-shared/src/schema-fields.ts, packages/stack-shared/src/config/schema.ts, packages/stack-shared/src/interface/crud/projects.ts, packages/stack-shared/src/utils/oauth.tsx, packages/stack-shared/src/config/schema-fuzzer.test.ts
Adds oauthNetSuiteAccountIdSchema; exposes netsuiteAccountId on environment OAuth provider schema and org defaults; adds netsuite_account_id to CRUD schema; appends "netsuite" to standardProviders; adds fuzzing example for netsuiteAccountId.
Dashboard UI changes
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx
Adds netsuite title mapping, netsuiteAccountId to provider form schema and defaults, conditional Account ID input for netsuite, and includes netsuiteAccountId in update payload for standard providers.
Branding & icons
packages/stack-ui/src/components/brand-icons.tsx
Adds Netsuite SVG component, maps netsuite to the icon/title, and adds netsuite brand color (#403C38).
Template types
packages/template/src/lib/stack-app/project-configs/index.ts
Adds optional netsuiteAccountId?: string to AdminOAuthProviderConfig for standard providers.
Tests
apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts
Extends expected allowed provider types literal to include netsuite in a test assertion.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Backend as Backend OAuth Controller
  participant Provider as NetSuiteProvider
  participant NetSuite as NetSuite OAuth2

  Client->>Backend: Start OAuth (provider=netsuite)
  Backend->>Provider: create({ clientId, clientSecret, accountId })
  Note right of Provider `#DDEBEF`: Configure issuer, auth/token endpoints, scopes
  Backend->>NetSuite: Redirect user to Authorization Endpoint
  NetSuite-->>Client: Login & consent
  Client->>Backend: Callback with code
  Backend->>NetSuite: Token request (code)
  NetSuite-->>Backend: TokenSet (access_token, expires)
  Backend->>Provider: postProcessUserInfo(TokenSet)
  Provider->>NetSuite: GET /userinfo (Bearer)
  NetSuite-->>Provider: User info JSON (may include accountId)
  Provider-->>Backend: OAuthUserInfo (accountId, email, name)
  Backend-->>Client: Session established
sequenceDiagram
  autonumber
  participant Scheduler as Token Checker
  participant Provider as NetSuiteProvider
  participant NetSuite as NetSuite OAuth2

  Scheduler->>Provider: checkAccessTokenValidity(accessToken)
  Provider->>NetSuite: GET /services/rest/.../oauth2/v1/userinfo (Bearer)
  alt 200 OK
    NetSuite-->>Provider: 200 OK
    Provider-->>Scheduler: true
  else non-OK / error
    NetSuite--x Provider: Error/Non-OK
    Provider-->>Scheduler: false
  end

Estimated code review effort

๐ŸŽฏ 4 (Complex) | โฑ๏ธ ~45 minutes

  • Areas needing focused review:
    • apps/backend/src/oauth/providers/netsuite.tsx โ€” userinfo parsing for multiple response shapes, accountId validation, token expiry handling.
    • Consistency of netsuiteAccountId (camelCase) vs netsuite_account_id (snake_case) across backend mappings, shared schemas, and DB/project wiring.
    • Dashboard form conditional rendering and payload submission path.
    • Schema additions in shared package for backward compatibility and OpenAPI metadata.

Possibly related PRs

  • stack-auth/stack-auth#835 โ€” touches apps/backend/src/lib/projects.tsx and modifies createOrUpdateProjectWithLegacyConfig; likely related to wiring changes for provider mapping and payload shape.

Poem

I hop through scopes with gentle might,
I add an Account ID to make things right,
I fetch userinfo by token's light,
I draw a new icon in brand-true sight,
I nibble bugs and ship delight. ๐Ÿ‡โœจ

Pre-merge checks and finishing touches

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (2 passed)
Check name Status Explanation
Title check โœ… Passed The title clearly and specifically summarizes the main change: introducing NetSuite as a new OAuth provider.
Description check โœ… Passed The description comprehensively covers the changes with clear sections on behavior, schemas, and misc updates, explaining the scope and rationale of the PR.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

๐Ÿ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between c1694938487ebee9d04bc40c877c9ad83f31c8ad and 0d05ba44c8f1b18c013294aa82033fd18adcb4f4.

๐Ÿ“’ Files selected for processing (1)
  • apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts (1 hunks)
โœ… Files skipped from review due to trivial changes (1)
  • apps/e2e/tests/backend/endpoints/api/v1/internal/config.test.ts
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 11 '25 14:09 coderabbitai[bot]

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

Project Deployment Preview Comments Updated (UTC)
stack-backend Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-dashboard Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-demo Ready Ready Preview Comment Nov 14, 2025 11:56pm
stack-docs Ready Ready Preview Comment Nov 14, 2025 11:56pm

vercel[bot] avatar Nov 14 '25 23:11 vercel[bot]