aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/otp.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-10 11:12:23 +0200
committerChocobozzz <me@florianbigard.com>2022-10-10 11:12:23 +0200
commita3e5f804ad821f6979e8735b0569b1209986fedc (patch)
tree5b34a6bd6b3cb1c5e3eed32a72d02922100d53dc /server/helpers/otp.ts
parenta0da6f90d16027b385a67da6a5691b163626a363 (diff)
downloadPeerTube-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.ts10
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 @@
1import { Secret, TOTP } from 'otpauth' 1import { Secret, TOTP } from 'otpauth'
2import { CONFIG } from '@server/initializers/config'
2import { WEBSERVER } from '@server/initializers/constants' 3import { WEBSERVER } from '@server/initializers/constants'
4import { decrypt } from './peertube-crypto'
3 5
4function isOTPValid (options: { 6async 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(),