exoauth 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/exoauth/auth.rb +45 -47
- data/lib/exoauth/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6413f8e41e505e8c5a9c53c019ff3f332bedaf0e036894b8dd84ba389eb73613
|
4
|
+
data.tar.gz: 8c489d53f0b37a7b76a28b84bce26543f9db2e2e09305e2f7fdfc615282b7f4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2207012fd67629753bab89a4daadfe9281b7cd86ea9e90446a8b81a83e91a4ad45210656c79e4bdc512ede84e1464d46d660e0ea0a4fc6fca62381dfed9c7eb1
|
7
|
+
data.tar.gz: 5918f7541a30e9fe82826c3c5a47b858b1c43b88092c3ebe1e7e88d8f9a744a4c4e2cd6bac046c4563cd3180d2e96c8d3c4485095cb8d5c01171b873371da641
|
data/README.md
CHANGED
data/lib/exoauth/auth.rb
CHANGED
@@ -97,6 +97,26 @@ module ExoAuth
|
|
97
97
|
pub_key
|
98
98
|
end
|
99
99
|
|
100
|
+
def self.key_from_string(str, algorithm)
|
101
|
+
key = nil
|
102
|
+
case algorithm
|
103
|
+
when 'HS256'
|
104
|
+
key = str
|
105
|
+
when 'ES384', 'ES512', 'RS256'
|
106
|
+
key = OpenSSL::PKey.read(str)
|
107
|
+
end
|
108
|
+
|
109
|
+
key
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.key_from_env(varname, algorithm)
|
113
|
+
Auth.key_from_string(ENV[varname], algorithm)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.key_from_settings(field, algorithm)
|
117
|
+
Auth.key_from_string(@@conf[field], algorithm)
|
118
|
+
end
|
119
|
+
|
100
120
|
def self.key_from_file(fname, algorithm)
|
101
121
|
key = nil
|
102
122
|
File.open(fname) do |file|
|
@@ -175,60 +195,38 @@ module ExoAuth
|
|
175
195
|
payload
|
176
196
|
end
|
177
197
|
rescue JWT::DecodeError => e
|
178
|
-
|
198
|
+
false
|
179
199
|
end
|
180
200
|
end
|
181
201
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
Auth.app_algorithm) :
|
204
|
-
nil
|
202
|
+
def self.init_app_key(conf, prefix)
|
203
|
+
if conf.key?("#{prefix}_key_path")
|
204
|
+
fname = File.expand_path(conf["#{prefix}_key_path"], __FILE__)
|
205
|
+
Auth.key_from_file(fname, Auth.app_algorithm)
|
206
|
+
elsif conf.key?("#{prefix}_key_env_variable")
|
207
|
+
varname = conf["#{prefix}_key_env_variable"]
|
208
|
+
Auth.key_from_env(varname, Auth.app_algorithm)
|
209
|
+
elsif conf.key?("#{prefix}_key")
|
210
|
+
field = "#{prefix}_key"
|
211
|
+
Auth.key_from_settings(field, Auth.app_algorithm)
|
212
|
+
elsif conf.key?("#{prefix}_enabled")
|
213
|
+
fname = File.expand_path(Auth::DEFAULT_VERIFY_KEY_PATH, __FILE__)
|
214
|
+
Auth.key_from_file(fname, Auth.app_algorithm)
|
215
|
+
else
|
216
|
+
nil
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
@@app_signing_key = Auth.init_app_key(@@conf, 'signing')
|
221
|
+
|
222
|
+
@@app_verify_key = Auth.init_app_key(@@conf, 'verify')
|
205
223
|
|
206
224
|
def self.settings_reloaded
|
207
225
|
@@conf = ExoBasic::Settings.loaded['user_auth']
|
208
226
|
|
209
|
-
@@app_signing_key =
|
210
|
-
|
211
|
-
|
212
|
-
Auth.key_from_file(
|
213
|
-
File.expand_path(
|
214
|
-
ExoBasic::Settings.try_get_key(@@conf,
|
215
|
-
Auth::DEFAULT_SIGNING_KEY_PATH,
|
216
|
-
'signing_key_path'),
|
217
|
-
__FILE__),
|
218
|
-
Auth.app_algorithm) :
|
219
|
-
nil
|
220
|
-
|
221
|
-
@@app_verify_key = ExoBasic::Settings.try_get_key(@@conf,
|
222
|
-
true,
|
223
|
-
'verify_enabled') ?
|
224
|
-
Auth.key_from_file(
|
225
|
-
File.expand_path(
|
226
|
-
ExoBasic::Settings.try_get_key(@@conf,
|
227
|
-
Auth::DEFAULT_VERIFY_KEY_PATH,
|
228
|
-
'verify_key_path'),
|
229
|
-
__FILE__),
|
230
|
-
Auth.app_algorithm) :
|
231
|
-
nil
|
227
|
+
@@app_signing_key = Auth.init_app_key(@@conf, 'signing')
|
228
|
+
|
229
|
+
@@app_verify_key = Auth.init_app_key(@@conf, 'verify')
|
232
230
|
end
|
233
231
|
|
234
232
|
def self.get_app_signing_key
|
data/lib/exoauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exoauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dionysios Kakolyris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: exobasic
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.2
|
41
41
|
description: Exotic Auth Helpers
|
42
42
|
email:
|
43
43
|
- contact@exotic.industries
|