Fix unnecessary requirement for deprecated OTP_SECRET environment variable (#34810)
This commit is contained in:
parent
198b59ca3e
commit
b7e967817b
3 changed files with 11 additions and 11 deletions
|
@ -150,13 +150,6 @@ Rails.application.configure do
|
||||||
'Referrer-Policy' => 'same-origin',
|
'Referrer-Policy' => 'same-origin',
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Remove once devise-two-factor data migration complete
|
|
||||||
config.x.otp_secret = if ENV['SECRET_KEY_BASE_DUMMY']
|
|
||||||
SecureRandom.hex(64)
|
|
||||||
else
|
|
||||||
ENV.fetch('OTP_SECRET')
|
|
||||||
end
|
|
||||||
|
|
||||||
# Enable DNS rebinding protection and other `Host` header attacks.
|
# Enable DNS rebinding protection and other `Host` header attacks.
|
||||||
# config.hosts = [
|
# config.hosts = [
|
||||||
# "example.com", # Allow requests from example.com
|
# "example.com", # Allow requests from example.com
|
||||||
|
|
|
@ -48,9 +48,6 @@ Rails.application.configure do
|
||||||
# Print deprecation notices to the stderr.
|
# Print deprecation notices to the stderr.
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
# TODO: Remove once devise-two-factor data migration complete
|
|
||||||
config.x.otp_secret = '100c7faeef00caa29242f6b04156742bf76065771fd4117990c4282b8748ff3d99f8fdae97c982ab5bd2e6756a159121377cce4421f4a8ecd2d67bd7749a3fb4'
|
|
||||||
|
|
||||||
# Generate random VAPID keys
|
# Generate random VAPID keys
|
||||||
vapid_key = Webpush.generate_key
|
vapid_key = Webpush.generate_key
|
||||||
config.x.vapid_private_key = vapid_key.private_key
|
config.x.vapid_private_key = vapid_key.private_key
|
||||||
|
|
|
@ -79,8 +79,18 @@ class MigrateDeviseTwoFactorSecrets < ActiveRecord::Migration[7.1]
|
||||||
class MigrationUser < ApplicationRecord
|
class MigrationUser < ApplicationRecord
|
||||||
self.table_name = :users
|
self.table_name = :users
|
||||||
|
|
||||||
|
LEGACY_OTP_SECRET = begin
|
||||||
|
if Rails.env.test?
|
||||||
|
'100c7faeef00caa29242f6b04156742bf76065771fd4117990c4282b8748ff3d99f8fdae97c982ab5bd2e6756a159121377cce4421f4a8ecd2d67bd7749a3fb4'
|
||||||
|
elsif ENV['SECRET_KEY_BASE_DUMMY']
|
||||||
|
SecureRandom.hex(64)
|
||||||
|
else
|
||||||
|
ENV.fetch('OTP_SECRET')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
devise :two_factor_authenticatable,
|
devise :two_factor_authenticatable,
|
||||||
otp_secret_encryption_key: Rails.configuration.x.otp_secret
|
otp_secret_encryption_key: LEGACY_OTP_SECRET
|
||||||
|
|
||||||
include LegacyOtpSecret
|
include LegacyOtpSecret
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue