Skip to content
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

feat(): enable custom domain usage #9911

Merged
merged 61 commits into from
Feb 7, 2025
Merged

Conversation

AMoreaux
Copy link
Contributor

@AMoreaux AMoreaux commented Jan 29, 2025

Content

  • Introduce the workspaceUrls property. It contains two sub-properties: customUrl, subdomainUrl. These endpoints are used to access the workspace. Even if the workspaceUrls is invalid for multiple reasons, the subdomainUrl remains valid.
  • Introduce ResolveField workspaceEndpoints to avoid unnecessary URL computation on the frontend part.
  • Add a forceSubdomainUrl to avoid custom URL using a query parameter

Replaces the previous migration for renaming 'domainName' to 'hostname' with a new approach that removes the 'hostname' column entirely. Introduces a new table, 'twoFactorMethod', for improved database design. Ensures proper handling of foreign keys and constraints during migration.
Removed the `domainName` field from the workspace entity and replaced it with a new `hostname` field. Updated associated TypeORM migration files to ensure database schema changes align with the updated entity structure. This improves the clarity and consistency of the field names.
Introduce utilities for handling subdomains, including generating random subdomains and deriving subdomain names from email or display names. Add support for hostname management with validation, updates, and domain registration in both backend and frontend, including GraphQL queries/mutations and UI integration. Updated related tests and resolvers for robustness.
…-and-migration-for-custom-domain

# Conflicts:
#	packages/twenty-front/src/generated-metadata/graphql.ts
#	packages/twenty-front/src/generated/graphql.tsx
Added a new `IsCustomDomainEnabled` feature flag to support custom domain functionality. Also replaced `domainName` with `hostname` in workspace-related GraphQL types for improved clarity.
Introduced hostname as a configurable and accessible property for workspaces. Updated GraphQL queries, mutations, DTOs, and frontend logic to handle the new hostname field. Improved hostname validation with stricter rules for custom hostnames.
Removed the `hostname` field from `UpdateWorkspaceInput` and renamed `domain` to `hostname`. Simplified the `getSubdomainFromEmail` function by removing unnecessary utility mocks and ensuring it returns only the subdomain. Adjusted related tests to align with the updated logic.
The `domain` field in the UpdateWorkspaceInput type has been removed. This change simplifies the input structure and aligns with updated API requirements.
The 'domain' field was removed from the UpdateWorkspaceInput type in the GraphQL schema as it is no longer used. This change helps clean up the codebase and avoid potential confusion or redundancy. No functional impact is expected as this field was not in active use.
Renamed isExist to isCloudflareInstanceDefined for better clarity and self-documentation. Added a validation schema using zod for subdomain input to enforce stricter validation rules. Included hostname as a nullable field and updated workspace repository call to use await.
…r-a-custom-domain

# Conflicts:
#	packages/twenty-front/src/generated/graphql.tsx
#	packages/twenty-front/src/modules/workspace/graphql/mutations/updateWorkspace.ts
Introduced hostname field to workspace types and relevant GraphQL queries, mutations, and fragments. Added new "GetHostnameDetails" query to fetch hostname-related ownership verification and status. Updated metadata with "IsRichTextV2Enabled" feature flag.
Removed unused validation schema from SettingsSubdomain and fixed a typo in a styled component name. Improved error handling in workspace service and enhanced hostname validation to include a max length. Minor updates to mock data for consistency.
Commented out unnecessary console logs and removed an unused variable in the updateWorkspace function. These changes improve code clarity and reduce potential noise in the console during execution.
Updated OwnershipVerification and related DTO fields to be nullable where appropriate for better alignment with API specifications. This ensures compatibility with optional data returned by the external API.
Revised the handling of custom hostname details by consolidating types and replacing redundant structures with a unified ownership verification model. Updated service methods and GraphQL schema accordingly for consistency and clarity. Removed deprecated logic and streamlined parameter handling.
… feat/enable-custom-domain-usage

# Conflicts:
#	packages/twenty-front/src/generated/graphql.tsx
#	packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts
…points

Transitioned codebase to use workspaceEndpoints structure instead of workspaceUrl. This enables support for both custom and default endpoints, ensuring better flexibility and alignment with updated API schemas.
Updated multiple methods and services to pass the workspace object instead of subdomain strings. This change simplifies and standardizes the handling of workspace details, reducing reliance on individual properties like subdomains across the codebase.
@AMoreaux AMoreaux self-assigned this Jan 29, 2025
@AMoreaux AMoreaux changed the base branch from main to feat/allow-to-register-a-custom-domain January 29, 2025 15:23
Removed the process.env.NODE_TLS_REJECT_UNAUTHORIZED setting, which could potentially introduce security risks. The code now adheres to default secure behavior for TLS connections.
Simplified the dependency array for useMemo in the useAuth hook by consolidating it into a single line. This improves readability without altering functionality.
…main-usage

# Conflicts:
#	packages/twenty-server/src/engine/middlewares/graphql-hydrate-request-from-token.middleware.ts
Renamed 'GetPublicWorkspaceDataBySubdomain' to 'GetPublicWorkspaceDataByDomain' in excluded middleware operations list. This ensures the name aligns with the updated operation logic or endpoint.
@FelixMalfait
Copy link
Member

Could we add a check for a billingEntitlement like we do for SSO? Could be called CUSTOM_DOMAIN

…main-usage

# Conflicts:
#	packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpGlobalScopeForm.tsx
#	packages/twenty-front/src/modules/domain-manager/hooks/useBuildWorkspaceUrl.ts
#	packages/twenty-front/src/modules/domain-manager/hooks/useGetPublicWorkspaceDataByDomain.ts
#	packages/twenty-front/src/modules/domain-manager/hooks/useReadWorkspaceSubdomainFromCurrentLocation.ts
#	packages/twenty-front/src/modules/settings/admin-panel/hooks/useImpersonate.ts
#	packages/twenty-front/src/modules/workspace/components/WorkspaceProviderEffect.tsx
#	packages/twenty-front/src/pages/settings/workspace/SettingsHostname.tsx
#	packages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts
#	packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts
Deleted an unused hook to improve code maintainability and clarity. This hook was no longer referenced, ensuring cleaner and leaner code.
Replaced the isDefined import to use shared utilities for consistency across packages. Removed an unused hook import in SettingsHostname to clean up dependencies.
Eliminates unused imports related to DomainManagerService and CustomHostnameDetails in workspace services and resolver. This improves code cleanliness and reduces potential confusion. No functional changes introduced.
Introduced a feature to validate custom domain entitlement for workspaces. Added a new exception code and updated billing entitlement keys to support this functionality. This ensures proper handling of custom domain features based on subscription entitlements.
Added new test cases to validate handling of the CUSTOM_DOMAIN billing entitlement in Stripe event transformations. Ensures consistent behavior when processing entitlement updates, including workspace-specific fields.
…main-usage

# Conflicts:
#	packages/twenty-server/src/engine/core-modules/admin-panel/__tests__/admin-panel.spec.ts
#	packages/twenty-server/src/engine/core-modules/admin-panel/admin-panel.service.ts
…main-usage

# Conflicts:
#	packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSSO.ts
#	packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
#	packages/twenty-server/src/engine/core-modules/auth/strategies/oidc.auth.strategy.ts
#	packages/twenty-server/src/engine/core-modules/auth/strategies/saml.auth.strategy.ts
#	packages/twenty-server/src/engine/core-modules/sso/dtos/get-authorization-url.input.ts
#	packages/twenty-server/src/engine/core-modules/sso/services/sso.service.ts
#	packages/twenty-server/src/engine/core-modules/sso/sso.resolver.ts
…riables

Introduce RoleDto type and getRoles query to support role-related operations. Add types for environment variables and their grouping, along with a new query getEnvironmentVariablesGrouped. Remove unused and redundant ESLint rule configurations.
…main-usage

# Conflicts:
#	packages/twenty-front/src/generated-metadata/graphql.ts
#	packages/twenty-front/src/generated/graphql.tsx
Updated the GraphQL schema to replace the subdomain attribute with workspaceUrls, encapsulating subdomainUrl and customUrl for better flexibility. Adjusted related queries, mutations, and fragments to align with the new structure.
…main-usage

# Conflicts:
#	packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.module.ts
#	packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts
The functionality related to "forceSubdomainUrl" has been completely removed from both the frontend and backend. This includes deleting associated hooks, parameters, logic paths, and configurations. The cleanup simplifies the codebase and eliminates unnecessary complexity.
The test file for useGetWorkspaceUrlFromWorkspaceUrls was deleted, likely due to irrelevance or refactoring efforts. This simplifies the codebase and removes unnecessary test coverage for deprecated or unused functionality.
Replaced useGetWorkspaceUrlFromWorkspaceUrls hook with a centralized utility function getWorkspaceUrl. This simplifies imports, removes redundant code, and improves maintainability by consolidating the logic into a shared utility module.
Removed redundant "false" argument when calling getSubdomainAndHostnameFromWorkspace. Also simplified subdomain retrieval logic in guard-redirect service for improved readability and maintainability. No functional changes introduced.
Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work!

@AMoreaux AMoreaux merged commit 68183b7 into main Feb 7, 2025
47 checks passed
@AMoreaux AMoreaux deleted the feat/enable-custom-domain-usage branch February 7, 2025 13:34
Copy link

github-actions bot commented Feb 7, 2025

Thanks @AMoreaux for your contribution!
This marks your 81st PR on the repo. You're top 1% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

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

Successfully merging this pull request may close these issues.

3 participants