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

[refactor]: Remove isSSOEnabled logic throughout the codebase #9462

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AMoreaux
Copy link
Contributor

@AMoreaux AMoreaux commented Jan 8, 2025

Eliminated all references to isSSOEnabled across the frontend, backend, and configuration files. This change simplifies the codebase by removing unnecessary feature flag checks, associated logic, and environment variables. The SSO feature remains available without reliance on this flag.

Eliminated all references to `isSSOEnabled` across the frontend, backend, and configuration files. This change simplifies the codebase by removing unnecessary feature flag checks, associated logic, and environment variables. The SSO feature remains available without reliance on this flag.
@AMoreaux AMoreaux requested a review from FelixMalfait January 8, 2025 17:01
@AMoreaux AMoreaux self-assigned this Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Warnings
⚠️ Changes were made to the environment variables, but not to the documentation - Please review your changes and check if a change needs to be documented!

Generated by 🚫 dangerJS against e0c18ee

if (environmentService.get('AUTH_SSO_ENABLED')) {
app.use(session(getSessionStorageOptions(environmentService)));
}
app.use(session(getSessionStorageOptions(environmentService)));

Check warning

Code scanning / CodeQL

Clear text transmission of sensitive cookie Medium

Sensitive cookie sent without enforcing SSL encryption.

Copilot Autofix AI about 19 hours ago

To fix the problem, we need to ensure that the secure attribute is set on the session cookies. This can be done by modifying the session configuration to include the secure attribute. Specifically, we should update the getSessionStorageOptions function to set the secure attribute based on the environment (e.g., only set it to true if the application is running in production).

  1. Update the getSessionStorageOptions function to include the secure attribute in the session cookie options.
  2. Ensure that the secure attribute is set to true when the application is running in a production environment.
Suggested changeset 1
packages/twenty-server/src/main.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/twenty-server/src/main.ts b/packages/twenty-server/src/main.ts
--- a/packages/twenty-server/src/main.ts
+++ b/packages/twenty-server/src/main.ts
@@ -14,2 +14,3 @@
 import { getSessionStorageOptions } from 'src/engine/core-modules/session-storage/session-storage.module-factory';
+import { SessionOptions } from 'express-session';
 import { UnhandledExceptionFilter } from 'src/filters/unhandled-exception.filter';
@@ -86,3 +87,5 @@
   // Enable session - Today it's used only for SSO
-  app.use(session(getSessionStorageOptions(environmentService)));
+  const sessionOptions: SessionOptions = getSessionStorageOptions(environmentService);
+  sessionOptions.cookie.secure = process.env.NODE_ENV === 'production';
+  app.use(session(sessionOptions));
 
EOF
@@ -14,2 +14,3 @@
import { getSessionStorageOptions } from 'src/engine/core-modules/session-storage/session-storage.module-factory';
import { SessionOptions } from 'express-session';
import { UnhandledExceptionFilter } from 'src/filters/unhandled-exception.filter';
@@ -86,3 +87,5 @@
// Enable session - Today it's used only for SSO
app.use(session(getSessionStorageOptions(environmentService)));
const sessionOptions: SessionOptions = getSessionStorageOptions(environmentService);
sessionOptions.cookie.secure = process.env.NODE_ENV === 'production';
app.use(session(sessionOptions));

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@AMoreaux
Copy link
Contributor Author

AMoreaux commented Jan 8, 2025

@FelixMalfait Do you want a command for the next migration to clean the flag in the database?

@charlesBochet
Copy link
Member

Let's wait for the deploy before merging this PR :)

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