etna 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c509ba77487fcda069ddf9083cddaa28b9a1cab2c6d6c62a681a6999e2bcd28a
4
- data.tar.gz: 10044f1c299846a87aa5d70e90deee34cf7e860e7f6df503f6d7aa5a7d880ea3
3
+ metadata.gz: d7ff510ea92327172e9682b7b07e65dc299d2f7246f7250ece8a2071891eb965
4
+ data.tar.gz: a13cb194bc64ae42ef76c0d2daf9ca6041ae46b37fd70db3c90752c80a479ae2
5
5
  SHA512:
6
- metadata.gz: 06062b4c110c17f2ae70ffba0bd3ac6d0b7e934a09f1f24553d22e2dddc106a1b5d9fad6172f31bf7355a28991364b7c6a8200eef8eec4854b7e76642733dd36
7
- data.tar.gz: f66ef71c2b257bf99dbcf29786c128affab8a1b480c4fa7ee958aed473979c356a0e2a9bba523c13b81f6a2a5481ea9c5f4ef36963382ab6bc5a8889d60b32ec
6
+ metadata.gz: d42498eecb1db7f476e004a7824f1e7b05c10685ded4da125d748c192ea7c2820c3efb3aff60fa7ed3ed026aace0503a12ed2ac61812ba23502925b19d674e99
7
+ data.tar.gz: d584c7eef1d6d874d8bf38d5eb046f91b29de1ec10485b89094ed52dcc8f29e8d43ec8da39fd97a5399a0eba7f9f0da14e340bb026f7b0cefac559d23d40aac9
@@ -355,8 +355,6 @@ class EtnaApp
355
355
  def execute(project_name, redcap_tokens, models: "all", commit: false)
356
356
  raise "Must provide at least one REDCap token (comma-separated)." unless redcap_tokens.split(',').length > 0
357
357
 
358
- raise "Your token is expired." if polyphemus_client.token_expired?
359
-
360
358
  puts "NOTE: This is a **preview** of what the data loading will look like. Use the --commit flag to load records into Magma." unless commit
361
359
 
362
360
  polyphemus_client.job(Etna::Clients::Polyphemus::RedcapJobRequest.new(
@@ -10,13 +10,15 @@ module Etna
10
10
  raise "#{self.class.name} client configuration is missing host." unless host
11
11
  raise "#{self.class.name} client configuration is missing token." unless token
12
12
 
13
+ @token = token
14
+ raise "Your token is expired." if token_expired?
15
+
13
16
  @etna_client = ::Etna::Client.new(
14
17
  host,
15
18
  token,
16
19
  routes_available: false,
17
20
  ignore_ssl: ignore_ssl)
18
21
  @host = host
19
- @token = token
20
22
  @ignore_ssl = ignore_ssl
21
23
  end
22
24
 
@@ -26,6 +28,7 @@ module Etna
26
28
  end
27
29
 
28
30
  def token_will_expire?(offset=3000)
31
+ # offset in seconds
29
32
  # Will the user's token expire in the given amount of time?
30
33
  epoch_seconds = JSON.parse(Base64.urlsafe_decode64(token.split('.')[1]))["exp"]
31
34
  expiration = DateTime.strptime(epoch_seconds.to_s, "%s")
@@ -7,7 +7,7 @@ module Etna
7
7
  class TestAuth < Auth
8
8
  def self.token_header(params)
9
9
  token = Base64.strict_encode64(params.to_json)
10
- return [ 'Authorization', "Etna #{token}" ]
10
+ return [ 'Authorization', "Etna something.#{token}" ]
11
11
  end
12
12
 
13
13
  def self.token_param(params)
@@ -36,8 +36,12 @@ module Etna
36
36
 
37
37
  return false unless token
38
38
 
39
- # here we simply base64-encode our user hash and pass it through
40
- payload = JSON.parse(Base64.decode64(token))
39
+ # Here we simply base64-encode our user hash and pass it through
40
+ # In order to behave more like "real" tokens, we expect the user hash to be
41
+ # in index 1 after splitting by ".".
42
+ # We do this to support Metis client tests, we pass in tokens with multiple "."-separated parts, so
43
+ # have to account for that.
44
+ payload = JSON.parse(Base64.decode64(token.split('.')[1]))
41
45
 
42
46
  request.env['etna.user'] = Etna::User.new(payload.map{|k,v| [k.to_sym, v]}.to_h, token)
43
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saurabh Asthana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack