-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(auth): refactor auth + allow to configure auth methods by workspace #8654
base: feat/add-is-multi-workspace-flag
Are you sure you want to change the base?
feat(auth): refactor auth + allow to configure auth methods by workspace #8654
Conversation
…t-auth-methods-by-workspace # Conflicts: # packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx # packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignInUpForm.ts
Remove unused imports from SignInUpGlobalScopeForm.tsx to improve code readability and reduce clutter. This change simplifies the module by eliminating unnecessary dependencies.
Suppress eslint warnings for console.error in error handling. This ensures cleaner code and maintains log output for better debugging.
Correct the expected state in useAuth test to reflect the accurate status of authProviders. This includes setting 'google' and 'password' to true, and initializing 'sso' as an empty array.
TODOs/FIXMEs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements workspace-specific authentication configuration, replacing the global auth settings with per-workspace controls for Google, Microsoft, Password, and SSO authentication methods.
- Added
isGoogleAuthEnabled
,isMicrosoftAuthEnabled
,isPasswordAuthEnabled
fields to/packages/twenty-server/src/engine/core-modules/workspace/workspace.entity.ts
for per-workspace auth control - Replaced global
IS_SIGN_UP_DISABLED
withIS_MULTIWORKSPACE_ENABLED
in server environment variables to support subdomain-based workspace access - Added new
WorkspaceProviderEffect
component in/packages/twenty-front/src/modules/workspace/components/WorkspaceProviderEffect.tsx
to manage workspace-specific auth state - Added
getPublicWorkspaceDataBySubdomain
query in workspace resolver to fetch workspace-specific auth configuration - Implemented SSO identity provider management with new types and mutations in
/packages/twenty-server/src/engine/core-modules/sso/
for OIDC and SAML support
88 file(s) reviewed, 66 comment(s)
Edit PR Review Bot Settings | Greptile
packages/twenty-front/src/modules/auth/graphql/queries/getPublicWorkspaceDataBySubdomain.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpEmailField.tsx
Show resolved
Hide resolved
packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpGlobalScopeForm.tsx
Show resolved
Hide resolved
packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpGlobalScopeForm.tsx
Show resolved
Hide resolved
import { CustomException } from 'src/utils/custom-exception'; | ||
|
||
export class WorkspaceException extends CustomException { | ||
code: WorkspaceExceptionCode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: code property is redundant since it's already passed to super and available through inheritance
if (!workspace) { | ||
return new WorkspaceException( | ||
'Workspace not found', | ||
WorkspaceExceptionCode.WORKSPACE_NOT_FOUND, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: throwing an exception would be more appropriate than returning it as a successful response
withSearchParams?: Record<string, string | number>; | ||
} = {}, | ||
) => { | ||
const url = new URL(baseUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: new URL() will throw if baseUrl is invalid. Consider wrapping in try/catch
) => { | ||
const url = new URL(baseUrl); | ||
|
||
url.hostname = subdomain ? `${subdomain}.${url.hostname}` : url.hostname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: subdomain should be sanitized to prevent invalid hostname characters
Object.entries(withSearchParams).forEach(([key, value]) => { | ||
url.searchParams.set(key, value.toString()); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: value.toString() on null/undefined will throw. Add null check
…lect-auth-methods-by-workspace
…lect-auth-methods-by-workspace # Conflicts: # packages/twenty-front/src/generated/graphql.tsx
Updated SSO identity provider type and added types for workspace queries. Removed deprecated mutations and queries related to SSO identity providers and JWT generation. Added new fields and types to support improved workspace querying and switching capabilities.
No description provided.