enviso 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/enviso.gemspec +1 -0
- data/lib/enviso/api.rb +3 -4
- data/lib/enviso/authentication.rb +13 -0
- data/lib/enviso/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d618e4e3a0373f44ce7ecbcd8a87fbb8509d35c995ae700f4fff130385807ff
|
4
|
+
data.tar.gz: 32fe913b71cbd584100f07148899f2c5c61b5d72c528ff21a76efd6b843784ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09dd98ef9da9931bfc19efc4ada6475a2582e6cfac1c9effffec77e67837f3516cf094f801425ae7bf5ef92f64df86e8780f16c4b67ca9896b1f2c0349203bb
|
7
|
+
data.tar.gz: 0f67c3bf869a9ec5ad29a535801c643ba1c2a6282a5476981d3cfb16e257ed2e8fc51deaa87e5c3a8ba2273111b57444e3e9401ba3df7fb0ac6a3455cabf8c66
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
enviso (0.1.
|
4
|
+
enviso (0.1.5)
|
5
|
+
jwt
|
5
6
|
openssl
|
6
7
|
rest-client
|
7
8
|
|
@@ -14,6 +15,7 @@ GEM
|
|
14
15
|
http-accept (1.7.0)
|
15
16
|
http-cookie (1.0.3)
|
16
17
|
domain_name (~> 0.5)
|
18
|
+
jwt (2.2.1)
|
17
19
|
mime-types (3.3)
|
18
20
|
mime-types-data (~> 3.2015)
|
19
21
|
mime-types-data (3.2019.1009)
|
data/enviso.gemspec
CHANGED
data/lib/enviso/api.rb
CHANGED
@@ -13,10 +13,9 @@ module Enviso::API
|
|
13
13
|
url = "#{Enviso::Config.api_link}v#{Enviso::Config.api_version}/#{endpoint}"
|
14
14
|
begin
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
16
|
+
# Get a new API token is the current one has expired.
|
17
|
+
unless Enviso::Authentication.has_valid_api_key || endpoint.include?("apis")
|
18
|
+
Enviso::Authentication.get_new_token
|
20
19
|
end
|
21
20
|
|
22
21
|
if Enviso::Config.verbose
|
@@ -2,6 +2,7 @@ module Enviso::Authentication
|
|
2
2
|
require 'digest'
|
3
3
|
require 'base64'
|
4
4
|
require 'openssl'
|
5
|
+
require 'jwt'
|
5
6
|
|
6
7
|
# The communication layer implements all the methods available in the Enviso API
|
7
8
|
class << self
|
@@ -88,6 +89,18 @@ module Enviso::Authentication
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
92
|
+
# Parses the current API key and checks if the 'exp' attribute
|
93
|
+
# represents a date in the future.
|
94
|
+
def has_valid_api_key
|
95
|
+
return self.auth_token != nil && api_key_valid_until > Time.now
|
96
|
+
end
|
97
|
+
|
98
|
+
def api_key_valid_until
|
99
|
+
decoded_token = JWT.decode self.auth_token, nil, false
|
100
|
+
Time.at(decoded_token.first["exp"])
|
101
|
+
end
|
102
|
+
|
91
103
|
end
|
104
|
+
|
92
105
|
init!
|
93
106
|
end
|
data/lib/enviso/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enviso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henk Meijer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jwt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: openssl
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|