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/2fa #9634

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

Feat/2fa #9634

wants to merge 2 commits into from

Conversation

nicolasrouanne
Copy link
Contributor

Description

Closes #7003
Implements 2FA with TOTP.

Warning

This is a draft PR, with only partial changes, made as a mean of discussion about #7003 (it's easier to reason about real code)

Behaviour

  • a totpSecret is stored for each user
  • use otplib to create a QR code and to validate an otp against an totpSecret (great demo website by otplib)
  • OTP is asked upon each login attempt

Source

Inspired by:

Remaining

  • encrypt totpSecret at rest using a symetric algorithm

Comment on lines 68 to 72
@Field(() => [TwoFactorMethod], { nullable: true })
@OneToMany(
() => TwoFactorMethod,
(twoFactorMethod) => twoFactorMethod.userWorkspace,
)
twoFactorMethods: Relation<TwoFactorMethod[]>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the twoFactorMethods relation in UserWorkspace, but for some reason, typeorm can't seem to find the association

/Users/nicolasrouanne/dev/twenty/src/metadata-builder/EntityMetadataBuilder.ts:1111
        entityMetadata.relations.forEach((relation) => {
                                 ^
TypeORMError: Entity metadata for UserWorkspace#twoFactorMethods was not found. Check if you specified a correct entity object and if it's connected in the connection options.
    at /Users/nicolasrouanne/dev/twenty/src/metadata-builder/EntityMetadataBuilder.ts:1121:23

- also add a `is2FAEnabled` column to `userWorkspace` entity
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.

2FA
3 participants