Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Change token_secret_signature_key default #264

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/knock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ module Knock

# Configure the key used to sign tokens.
mattr_accessor :token_secret_signature_key
self.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
self.token_secret_signature_key = -> do
if Rails.application.respond_to?(:secret_key_base)
Rails.application.secret_key_base
else
Rails.application.secrets.secret_key_base
end
end

# Configure the public key used to decode tokens, when required.
mattr_accessor :token_public_key
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/initializers/knock.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Knock.setup do |config|
config.token_signature_algorithm = 'HS256'
config.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
config.token_secret_signature_key = -> { Rails.application.secret_key_base }
config.token_public_key = nil
config.token_audience = nil

Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ActiveSupport::TestCase

def reset_knock_configuration
Knock.token_signature_algorithm = 'HS256'
Knock.token_secret_signature_key = -> { Rails.application.secrets.secret_key_base }
Knock.token_secret_signature_key = -> { Rails.application.secret_key_base }
Knock.token_public_key = nil
Knock.token_audience = nil
Knock.token_lifetime = 1.day
Expand Down