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

Use uuid package instead of crypto package #9191

Merged
merged 1 commit into from
Dec 23, 2024
Merged

Use uuid package instead of crypto package #9191

merged 1 commit into from
Dec 23, 2024

Conversation

FelixMalfait
Copy link
Member

Fixes #9186

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 replaces the crypto package with uuid v4 for generating unique identifiers, addressing console errors in Docker environments without HTTPS configuration.

  • Replaced crypto.randomUUID() with uuid.v4() in /packages/twenty-front/src/modules/analytics/hooks/useEventTracker.ts for session ID generation
  • Modified /packages/twenty-front/src/modules/settings/security/utils/sSOIdentityProviderDefaultValues.ts to use uuid.v4() for SSO provider ID generation
  • Maintains secure cookie settings with 'secure' flag in analytics tracking
  • Simplifies UUID generation code while preserving functionality across all environments

2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))
).toString(16),
),
id: v4(),
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The OIDC provider is missing an 'id' field while SAML has one. This inconsistency could cause issues with provider identification.

Copy link
Member Author

Choose a reason for hiding this comment

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

@AMoreaux good point raised by Geptile, is there a reason for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it's expected. It's because to generate the saml provider we need to know the id before save the row. For OIDC it's useless.

@@ -19,7 +20,7 @@ export const getSessionId = (): string => {
};

export const setSessionId = (domain?: string): void => {
const sessionId = getSessionId() || crypto.randomUUID();
const sessionId = getSessionId() || v4();
const baseCookie = `${ANALYTICS_COOKIE_NAME}=${sessionId}; Max-Age=1800; path=/; secure`;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Cookie lacks 'SameSite' attribute which is recommended for secure cookies

@AMoreaux AMoreaux merged commit 164f010 into main Dec 23, 2024
22 checks passed
@AMoreaux AMoreaux deleted the fix-9186 branch December 23, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crypto error when not using https
2 participants