mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
find auto-generated secret_key_base in development (#4869)
With this fix, we will try latest changes in Rails 5.2 together with standard auto-generated secret_key_base in development as a fallback. If no specified key found, auto-generated value will be used instead.
This commit is contained in:
parent
246a50876a
commit
6c916488af
2 changed files with 26 additions and 0 deletions
|
@ -13,6 +13,8 @@ module Devise
|
||||||
@application.secrets.secret_key_base
|
@application.secrets.secret_key_base
|
||||||
elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config)
|
elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config)
|
||||||
@application.config.secret_key_base
|
@application.config.secret_key_base
|
||||||
|
elsif @application.respond_to?(:secret_key_base) && key_exists?(@application)
|
||||||
|
@application.secret_key_base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,24 @@ class Rails52Config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Rails52SecretKeyBase
|
||||||
|
def credentials
|
||||||
|
OpenStruct.new(secret_key_base: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def secrets
|
||||||
|
OpenStruct.new(secret_key_base: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def config
|
||||||
|
OpenStruct.new(secret_key_base: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def secret_key_base
|
||||||
|
'secret_key_base'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Rails41Secrets
|
class Rails41Secrets
|
||||||
def secrets
|
def secrets
|
||||||
OpenStruct.new(secret_key_base: 'secrets')
|
OpenStruct.new(secret_key_base: 'secrets')
|
||||||
|
@ -77,6 +95,12 @@ class SecretKeyFinderTest < ActiveSupport::TestCase
|
||||||
assert_equal 'config', secret_key_finder.find
|
assert_equal 'config', secret_key_finder.find
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "rails 5.2 uses secret_key_base when config is empty" do
|
||||||
|
secret_key_finder = Devise::SecretKeyFinder.new(Rails52SecretKeyBase.new)
|
||||||
|
|
||||||
|
assert_equal 'secret_key_base', secret_key_finder.find
|
||||||
|
end
|
||||||
|
|
||||||
test "rails 4.1 uses secrets" do
|
test "rails 4.1 uses secrets" do
|
||||||
secret_key_finder = Devise::SecretKeyFinder.new(Rails41Secrets.new)
|
secret_key_finder = Devise::SecretKeyFinder.new(Rails41Secrets.new)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue