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(auth): refactor auth + allow to configure auth methods by workspace #8654

Conversation

AMoreaux
Copy link
Contributor

No description provided.

…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.
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.

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 with IS_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

@AMoreaux AMoreaux changed the base branch from main to feat/add-is-multi-workspace-flag November 21, 2024 16:33
…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.
refactor(auth): thanks greptile
```
Move import of workspaceValidator to maintain consistent import structure. This enhances readability and aligns with the project's import organization standards.
Removed unused imports from SignInUpGlobalScopeForm and SettingsSecurityOptionsList components. This cleanup improves code readability and reduces potential maintenance overhead.
Added `GET_PUBLIC_WORKSPACE_DATA_BY_SUBDOMAIN` query mock handler to return mock workspace data. Also updated the button text check in SignInUp stories for consistency.
…main

Introduced a GraphQL query mock for the GET_PUBLIC_WORKSPACE_DATA_BY_SUBDOMAIN query in the testing setup. This includes relevant mock data and necessary imports for thorough test coverage. Additionally, fixed a typo in the mock configuration from isMultiworkspaceEnabled to isMultiWorkspaceEnabled and updated enums for status and type in SSOIdentityProvider.
The Pull Request introduces new authentication provider columns to the
Workspace entity and updates various services and modules to accommodate
these changes. It also includes the creation of a new WorkspaceException
class.
- Adds new columns to the Workspace entity for managing authentication
providers.
- Modifies several services (AuthService, WorkspaceService,
SignInUpService, etc.) to utilize the new columns.
- Introduces WorkspaceException for better error handling in
workspace-related operations.
- Updates tests and modules to accommodate the new columns and
exception.
- Includes code format and refactoring for improved readability and
maintainability.
}, [authProviders, continueWithEmail, signInUpStep]);

useEffect(() => {
checkAuthProviders();
Copy link
Member

Choose a reason for hiding this comment

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

we don't put useEffects in components, we can merge with that and discuss together how to fix it


useEffect(() => {
try {
if (isDefined(workspacePublicData?.logo)) {
Copy link
Member

Choose a reason for hiding this comment

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

weird to do that in a useEffect and manipulating the DOM, can't we edit the head direclty?

import { User } from 'src/engine/core-modules/user/user.entity';
import { CustomException } from 'src/utils/custom-exception';

const assertIsExist = (
Copy link
Member

Choose a reason for hiding this comment

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

assertExists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it means if it does not exist it throws.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isExist = return false
assertIsExist = throw

@AMoreaux AMoreaux merged commit 54aeca6 into feat/add-is-multi-workspace-flag Nov 26, 2024
17 checks passed
@AMoreaux AMoreaux deleted the feat/allow-to-select-auth-methods-by-workspace branch November 26, 2024 17:08
Copy link

Thanks @AMoreaux for your contribution!
This marks your 11th PR on the repo. You're top 3% 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.

2 participants