diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-10 11:12:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-10 11:12:23 +0200 |
commit | a3e5f804ad821f6979e8735b0569b1209986fedc (patch) | |
tree | 5b34a6bd6b3cb1c5e3eed32a72d02922100d53dc /server/helpers/otp.ts | |
parent | a0da6f90d16027b385a67da6a5691b163626a363 (diff) | |
download | PeerTube-a3e5f804ad821f6979e8735b0569b1209986fedc.tar.gz PeerTube-a3e5f804ad821f6979e8735b0569b1209986fedc.tar.zst PeerTube-a3e5f804ad821f6979e8735b0569b1209986fedc.zip |
Encrypt OTP secret
Diffstat (limited to 'server/helpers/otp.ts')
-rw-r--r-- | server/helpers/otp.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/helpers/otp.ts b/server/helpers/otp.ts index a13edc5e2..a32cc9621 100644 --- a/server/helpers/otp.ts +++ b/server/helpers/otp.ts | |||
@@ -1,11 +1,15 @@ | |||
1 | import { Secret, TOTP } from 'otpauth' | 1 | import { Secret, TOTP } from 'otpauth' |
2 | import { CONFIG } from '@server/initializers/config' | ||
2 | import { WEBSERVER } from '@server/initializers/constants' | 3 | import { WEBSERVER } from '@server/initializers/constants' |
4 | import { decrypt } from './peertube-crypto' | ||
3 | 5 | ||
4 | function isOTPValid (options: { | 6 | async function isOTPValid (options: { |
5 | secret: string | 7 | encryptedSecret: string |
6 | token: string | 8 | token: string |
7 | }) { | 9 | }) { |
8 | const { token, secret } = options | 10 | const { token, encryptedSecret } = options |
11 | |||
12 | const secret = await decrypt(encryptedSecret, CONFIG.SECRETS.PEERTUBE) | ||
9 | 13 | ||
10 | const totp = new TOTP({ | 14 | const totp = new TOTP({ |
11 | ...baseOTPOptions(), | 15 | ...baseOTPOptions(), |