这是indexloc提供的服务,不要输入任何密码
Skip to content

Remove legacy tenancy config #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open

Remove legacy tenancy config #802

wants to merge 17 commits into from

Conversation

fomalhautb
Copy link
Contributor

@fomalhautb fomalhautb commented Jul 24, 2025


Important

Refactor codebase to remove legacy tenancy configuration, updating domain, OAuth, email, and permission handling to use new config structure.

  • Behavior:
    • Refactor to use tenancy.config instead of tenancy.completeConfig in multiple files for domains, OAuth providers, and email configurations.
    • Update validateRedirectUrl() to use tenancy.config.domains.trustedDomains.
    • Modify getProvider() to handle provider.isShared and provider.type.
  • Domains:
    • Update domain handling in crud.tsx files for custom and neon integrations to use trustedDomains.
  • OAuth Providers:
    • Refactor OAuth provider logic in crud.tsx files to use new config structure.
    • Adjust getProviderConfig() and related functions to accommodate new config.
  • Emails:
    • Change email template and theme handling to use tenancy.config.emails.
    • Update email sending logic to reflect new email configuration structure.
  • Permissions:
    • Refactor permission handling functions to use tenancy.config.rbac.permissions.
  • Misc:
    • Update tests in send-sign-in-code.test.ts to reflect changes in OTP sign-in logic.
    • Minor refactoring in prisma-client.tsx to align with new tenancy config.

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

Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 11:11pm
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 11:11pm
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 11:11pm
stack-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 11:11pm

Copy link

recurseml bot commented Jul 24, 2025

😱 Found 1 issue. Time to roll up your sleeves! 😱

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

⚠️ Only 5 files were analyzed due to processing limits.

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

@fomalhautb fomalhautb marked this pull request as ready for review July 24, 2025 22:06
@fomalhautb fomalhautb assigned N2D4 and unassigned fomalhautb Jul 24, 2025
@fomalhautb fomalhautb requested a review from N2D4 July 24, 2025 22:06
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR represents a comprehensive refactoring to remove legacy tenancy configuration patterns throughout the Stack Auth codebase. The changes migrate from a dual configuration system (with both config and completeConfig properties) to a unified, hierarchical configuration structure.

The key architectural changes include:

  1. Configuration Structure Modernization: The PR eliminates the legacy completeConfig property from tenancy objects and consolidates all configuration access through the config property, which now directly contains the rendered organization configuration.

  2. Hierarchical Configuration Schema: The flat configuration structure has been replaced with a nested organization where related settings are grouped logically:

    • Authentication settings moved from credential_enabled, sign_up_enabled, passkey_enabled to auth.password.allowSignIn, auth.allowSignUp, auth.passkey.allowSignIn
    • Domain configuration restructured from flat arrays to domains.trustedDomains objects with baseUrl and handlerPath properties
    • OAuth providers reorganized from arrays to keyed objects under auth.oauth.providers
    • Email configuration moved from email_config.type to emails.server.isShared
  3. API Simplification: Functions like validateRedirectUrl have been updated to accept entire tenancy objects instead of individual configuration parameters, centralizing configuration access logic and reducing parameter coupling.

  4. Transformation Layer: The renderedOrganizationConfigToProjectCrud function is now used to transform the new organization config format into the expected project CRUD interface format for API responses, maintaining backward compatibility while supporting the new internal structure.

  5. New Environment Config CRUD: A new environment configuration management system has been introduced with proper CRUD operations, supporting the transition from legacy tenancy-based configuration to environment-level configuration management.

The changes affect authentication flows (password, OTP, passkey, OAuth), email systems, domain validation, API key management, team creation, user management, and various internal configuration endpoints. All modifications maintain functional equivalence while adopting the cleaner, more maintainable configuration architecture.

Confidence score: 3/5

• This PR has significant architectural changes that could introduce subtle bugs if configuration transformations are incorrect
• The migration from legacy to new config structure requires careful validation to ensure all property mappings are accurate
• Files like apps/backend/src/app/api/latest/auth/otp/send-sign-in-code/route.tsx have inconsistent error messaging and several files use generic yupMixed() validation that lacks type safety

46 files reviewed, 6 comments

Edit Code Review Bot Settings | Greptile

fomalhautb and others added 6 commits July 25, 2025 00:29
…ers/crud.tsx

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…te.tsx

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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