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 +4 -4
- data/lib/api_guard.rb +2 -0
- data/lib/api_guard/app_secret_key.rb +20 -0
- data/lib/api_guard/engine.rb +1 -4
- data/lib/api_guard/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b7ce3ac5306ae3a652084d29da83f37ec9b41c5
|
4
|
+
data.tar.gz: 7fb6b919ed4044e459a3840e442505326bfda971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02605d2b473c9931a1c494203562ae9e87ef90d5b3adfa4e043aba6b96e3da7aa3fc306189139a4d546b7b88eb4ecbdb876783dab28b9e6879b37dcca2f1c97
|
7
|
+
data.tar.gz: 293b709e2ae69d3b07912c319d5fd37c8ae3156797cf09b19aa55ab8bc317e90822747a3b3d0a856c368d0e16d8a89cdb7b6ca208d047e9dc5142db81db385d8
|
data/lib/api_guard.rb
CHANGED
@@ -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
|
data/lib/api_guard/engine.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/api_guard/version.rb
CHANGED
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.
|
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-
|
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
|