From 56f47830758ff8e92abcfcc5f35d474ab12fe215 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Oct 2022 15:37:15 +0200 Subject: Support two factor authentication in backend --- server/initializers/constants.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/initializers/constants.ts') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 9257ebf93..9d6087867 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -25,7 +25,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 740 +const LAST_MIGRATION_VERSION = 745 // --------------------------------------------------------------------------- @@ -640,6 +640,8 @@ const BCRYPT_SALT_SIZE = 10 const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days +const TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME = 60000 * 10 // 10 minutes + const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { @@ -805,6 +807,10 @@ const REDUNDANCY = { } const ACCEPT_HEADERS = [ 'html', 'application/json' ].concat(ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS) +const OTP = { + HEADER_NAME: 'x-peertube-otp', + HEADER_REQUIRED_VALUE: 'required; app' +} const ASSETS_PATH = { DEFAULT_AUDIO_BACKGROUND: join(root(), 'dist', 'server', 'assets', 'default-audio-background.jpg'), @@ -986,6 +992,7 @@ export { FOLLOW_STATES, DEFAULT_USER_THEME_NAME, SERVER_ACTOR_NAME, + TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME, PLUGIN_GLOBAL_CSS_FILE_NAME, PLUGIN_GLOBAL_CSS_PATH, PRIVATE_RSA_KEY_SIZE, @@ -1041,6 +1048,7 @@ export { PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, ASSETS_PATH, FILES_CONTENT_HASH, + OTP, loadLanguages, buildLanguages, generateContentHash -- cgit v1.2.3 From a3e5f804ad821f6979e8735b0569b1209986fedc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 Oct 2022 11:12:23 +0200 Subject: Encrypt OTP secret --- server/initializers/constants.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/initializers/constants.ts') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 9d6087867..cab61948a 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -1,5 +1,5 @@ import { RepeatOptions } from 'bullmq' -import { randomBytes } from 'crypto' +import { Encoding, randomBytes } from 'crypto' import { invert } from 'lodash' import { join } from 'path' import { randomInt, root } from '@shared/core-utils' @@ -637,6 +637,13 @@ let PRIVATE_RSA_KEY_SIZE = 2048 // Password encryption const BCRYPT_SALT_SIZE = 10 +const ENCRYPTION = { + ALGORITHM: 'aes-256-cbc', + IV: 16, + SALT: 'peertube', + ENCODING: 'hex' as Encoding +} + const USER_PASSWORD_RESET_LIFETIME = 60000 * 60 // 60 minutes const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days @@ -959,6 +966,7 @@ const VIDEO_FILTERS = { export { WEBSERVER, API_VERSION, + ENCRYPTION, VIDEO_LIVE, PEERTUBE_VERSION, LAZY_STATIC_PATHS, -- cgit v1.2.3