0
0
Fork 0

Move self destruct check to config_for and add constant for verifier string (#32943)

This commit is contained in:
Matt Jankowski 2024-11-18 04:57:16 -05:00 committed by GitHub
parent 911d7dbbf6
commit c0c34d35e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 12 deletions

View file

@ -1,9 +1,11 @@
# frozen_string_literal: true
module SelfDestructHelper
VERIFY_PURPOSE = 'self-destruct'
def self.self_destruct?
value = ENV.fetch('SELF_DESTRUCT', nil)
value.present? && Rails.application.message_verifier('self-destruct').verify(value) == ENV['LOCAL_DOMAIN']
value = Rails.configuration.x.mastodon.self_destruct_value
value.present? && Rails.application.message_verifier(VERIFY_PURPOSE).verify(value) == ENV['LOCAL_DOMAIN']
rescue ActiveSupport::MessageVerifier::InvalidSignature
false
end