api_guard 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bbc1b32deafff68b420cf4b56f343d67a90caa7
4
- data.tar.gz: 5b7f2aa8e25c5fd1fdbf5c4d21d99fb3461ecf33
3
+ metadata.gz: 6b7ce3ac5306ae3a652084d29da83f37ec9b41c5
4
+ data.tar.gz: 7fb6b919ed4044e459a3840e442505326bfda971
5
5
  SHA512:
6
- metadata.gz: cc4e72c586bae02e4f5bb9671e070625f58c88152924ff1448cd2b7d0ce805aa6f47db48ee8359b6411321e1333ddf3ae121ce2ba85a5a1d20471101cf7d16a2
7
- data.tar.gz: 8284feb1676f32b989735c9097f5f1c2e329f6e150ab2ebed2fba4b622a7c1eb7b9ba7186f01f049738a8d5a4920c857e23de9a96b0eef09c8b3be715b29b3ea
6
+ metadata.gz: e02605d2b473c9931a1c494203562ae9e87ef90d5b3adfa4e043aba6b96e3da7aa3fc306189139a4d546b7b88eb4ecbdb876783dab28b9e6879b37dcca2f1c97
7
+ data.tar.gz: 293b709e2ae69d3b07912c319d5fd37c8ae3156797cf09b19aa55ab8bc317e90822747a3b3d0a856c368d0e16d8a89cdb7b6ca208d047e9dc5142db81db385d8
data/lib/api_guard.rb CHANGED
@@ -3,6 +3,8 @@ require "api_guard/route_mapper"
3
3
  require "api_guard/modules"
4
4
 
5
5
  module ApiGuard
6
+ autoload :AppSecretKey, 'api_guard/app_secret_key'
7
+
6
8
  module Test
7
9
  autoload :ControllerHelper, 'api_guard/test/controller_helper'
8
10
  end
@@ -0,0 +1,20 @@
1
+ module ApiGuard
2
+ class AppSecretKey
3
+ def initialize(application)
4
+ @application = application
5
+ end
6
+
7
+ def detect
8
+ secret_key_base(:credentials) || secret_key_base(:secrets) ||
9
+ secret_key_base(:config) || secret_key_base
10
+ end
11
+
12
+ private
13
+
14
+ def secret_key_base(source = nil)
15
+ return @application.secret_key_base unless source
16
+
17
+ @application.send(source).secret_key_base.presence if @application.respond_to?(source)
18
+ end
19
+ end
20
+ end
@@ -9,10 +9,7 @@ module ApiGuard
9
9
 
10
10
  # Use 'secret_key_base' from Rails secrets if 'token_signing_secret' is not configured
11
11
  initializer 'ApiGuard.token_signing_secret' do |app|
12
- unless ApiGuard.token_signing_secret
13
- signing_secret = app.respond_to?(:credentials) ? app.credentials.secret_key_base : app.secrets.secret_key_base
14
- ApiGuard.token_signing_secret = signing_secret
15
- end
12
+ ApiGuard.token_signing_secret ||= ApiGuard::AppSecretKey.new(app).detect
16
13
  end
17
14
  end
18
15
  end
@@ -1,3 +1,3 @@
1
1
  module ApiGuard
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gokul Murali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -169,6 +169,7 @@ files:
169
169
  - app/views/layouts/api_guard/application.html.erb
170
170
  - config/routes.rb
171
171
  - lib/api_guard.rb
172
+ - lib/api_guard/app_secret_key.rb
172
173
  - lib/api_guard/engine.rb
173
174
  - lib/api_guard/jwt_auth/authentication.rb
174
175
  - lib/api_guard/jwt_auth/blacklist_token.rb