exoauth 0.1.0 → 0.1.1
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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 456dcc39fe3e7ec3fc82d5a1ffaeaf2e96b27c508cd31d7684b8d3c6483a262d
|
4
|
+
data.tar.gz: ede542d5edd11be158c01fba4f1a364f62cb9a47dfb19dfb79c68c719fa33f0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c68fc8d512b173d8e6413202d1a75d67ba210dd83795768714b0037ad1a4e3575b0d341e07d6f3df4d1421948cc279c8594515938e78b0acf1d7ed3dd4cb9a8
|
7
|
+
data.tar.gz: 872a4d6381b68f4bd9e2b17f9a9f2c2f2716f575ae92931d53b2970f088b1b905b93ef8a5756917405187cc7ca17ebb2cf9ee144e5411c055769bd4220df25ca
|
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.1
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|