-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Feature flags env variable gating #9481
base: main
Are you sure you want to change the base?
Feature flags env variable gating #9481
Conversation
Added support for multi-workspace checks during impersonation and streamlined token verification flows. Adjusted session clearing and navigation logic to improve user transition between workspaces.
…nation flow Simplified test assertions in `useAuth.test.tsx` by removing redundant property checks from the signup method. Enhanced `useImpersonate` hook by refactoring workspace condition logic and introducing fresh metadata states to improve session handling.
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 feature flag access control in the admin panel based on environment variables. Here's a focused review of the key changes:
- Added
useFeatureFlagManagementCapability
hook to gate feature flag management based onIS_BILLING_ENABLED
orDEBUG_MODE
environment variables - Modified
SettingsAdminContent
to conditionally render feature flag controls based on user capabilities - Added server-side capability check in
AdminPanelResolver
but missing validation inupdateWorkspaceFeatureFlags
service method - Improved state management in
useAuth
andVerifyEffect
for better token verification flow - Removed unnecessary assertions in
useAuth.test.tsx
that could miss response structure issues
The critical security issue is that the updateWorkspaceFeatureFlags
service method doesn't validate the user's capability before allowing updates, which could bypass the intended access control. This should be addressed before merging.
11 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -268,6 +268,8 @@ export const useAuth = () => { | |||
|
|||
const handleVerify = useCallback( | |||
async (loginToken: string) => { | |||
setIsVerifyPendingState(true); |
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: setIsVerifyPendingState(true) should be wrapped in try/catch to ensure it gets set back to false if verification fails
if (isDefined(loginToken)) { | ||
setIsAppWaitingForFreshObjectMetadata(true); | ||
verify(loginToken); | ||
} else if (!isLogged) { |
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: verify() returns a Promise but it's not being awaited. This could lead to race conditions if the verification fails and the component unmounts before completion.
...es/twenty-front/src/modules/settings/admin-panel/hooks/useFeatureFlagManagementCapability.ts
Outdated
Show resolved
Hide resolved
...front/src/modules/settings/admin-panel/graphql/queries/getFeatureFlagManagementCapability.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/engine/core-modules/admin-panel/admin-panel.service.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminContent.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/engine/core-modules/admin-panel/admin-panel.service.ts
Outdated
Show resolved
Hide resolved
packages/twenty-server/src/engine/core-modules/admin-panel/dtos/user-lookup.entity.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
if (isDefined(loginToken)) { | ||
setIsAppWaitingForFreshObjectMetadata(true); |
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.
It would be good to give a bit more context in your PR description when you introduce something like that as it doesn't directly relate to the original issue / I'm not sure exactly what problem we're solving here (race condition / dual execution?). Seems similar to topics discussed here: #9288
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.
cc @AMoreaux
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.
Two commits come from this PR #9451
It allows impersonation on the same workspace.
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.
👍
closes #9032