cased-ruby 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5356c39c08774c8e104858515fbb9111264c526e72984dd9da83874f87107903
4
- data.tar.gz: 4ca2cf761ef6d0abc7110988f38038d952bec2be593d4ae2e01a291b46c5cb69
3
+ metadata.gz: 136251a6fad727d85e14bf64bfdb5ecf33fdba19735646c3599398c7a0e44abb
4
+ data.tar.gz: 94f191ec590bc6bd68ef98b137abbaa052c8438573bb84d9cb9b63ffec4ae8e4
5
5
  SHA512:
6
- metadata.gz: 04b3651c4658c938257d333f167ab7846f9d7d9efe9a162e3986457af8acf86431ee4bc2b12ed393aed92073474da7f78c0283e584a82deb207041002c9d7bd0
7
- data.tar.gz: de40f52b7145f88ea18c6f9cfeaa5508a025e3f0d4498db9bd8821f45ba6b412804745f01ffb5ea13cbdc1ba942ac6496f622305af4ba705e6a2d94ccddb5390
6
+ metadata.gz: 613409847cfcda2948b2b3559a754ac6822fca908cec0d1a089475be19801290bf8aee866e592d00bef882b1e3b7027ead484346bd39a404c171b8205a5631fa
7
+ data.tar.gz: 3a3d8435ecce240a7cff4a83061c57412d08dd1d16e91c9995caf1f755a4706f40744e7ce11c015a4557d66ea1948b6c54caf05f893205a2f8296aedb9780e7b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cased-ruby (0.4.3)
4
+ cased-ruby (0.4.4)
5
5
  activesupport (~> 6)
6
6
  dotpath (= 0.1.0)
7
7
  faraday (~> 1.0)
data/README.md CHANGED
@@ -135,7 +135,8 @@ end
135
135
 
136
136
  authentication = Cased::CLI::Authentication.new
137
137
  identity = Cased::CLI::Identity.new
138
- authentication.token = identity.identify
138
+ token, ip_address = identity.identify
139
+ authentication.token = token
139
140
 
140
141
  session = Cased::CLI::Session.new(
141
142
  authentication: authentication,
@@ -23,15 +23,20 @@ module Cased
23
23
  def poll(poll_url)
24
24
  count = 0
25
25
  user_id = nil
26
+ ip_address = nil
26
27
 
27
28
  while user_id.nil?
28
29
  count += 1
29
30
  response = Cased.clients.cli.get(poll_url)
30
- user_id = response.body.dig('user', 'id')
31
- sleep 1 if user_id.nil?
31
+ if response.success?
32
+ user_id = response.body.dig('user', 'id')
33
+ ip_address = response.body.fetch('ip_address')
34
+ else
35
+ sleep 1
36
+ end
32
37
  end
33
38
 
34
- user_id
39
+ [user_id, ip_address]
35
40
  end
36
41
  end
37
42
  end
@@ -50,7 +50,9 @@ module Cased
50
50
  Cased::CLI::Log.log "You must re-authenticate with Cased due to recent changes to this application's settings."
51
51
 
52
52
  identity = Cased::CLI::Identity.new
53
- session.authentication.token = identity.identify
53
+ token, ip_address = identity.identify
54
+ session.authentication.token = token
55
+ session.forwarded_ip_address = ip_address
54
56
 
55
57
  create
56
58
  elsif session.unauthorized?
@@ -61,7 +63,9 @@ module Cased
61
63
  end
62
64
 
63
65
  identity = Cased::CLI::Identity.new
64
- session.authentication.token = identity.identify
66
+ token, ip_address = identity.identify
67
+ session.authentication.token = token
68
+ session.forwarded_ip_address = ip_address
65
69
 
66
70
  create
67
71
  elsif session.reason_required?
@@ -86,9 +86,17 @@ module Cased
86
86
  # @return [String, nil]
87
87
  attr_accessor :reason
88
88
 
89
+ # Public: The forwarded IP V4 or IP V6 address of the user that initiated
90
+ # the CLI session.
91
+ #
92
+ # @example
93
+ # session.forwarded_ip_address #=> "1.1.1.1"
94
+ # @return [String, nil]
95
+ attr_accessor :forwarded_ip_address
96
+
89
97
  # Public: The client's IP V4 or IP V6 address that initiated the CLI session.
90
98
  # @example
91
- # session.reason #=> "1.1.1.1"
99
+ # session.ip_address #=> "1.1.1.1"
92
100
  # @return [String, nil]
93
101
  attr_reader :ip_address
94
102
 
@@ -144,6 +152,7 @@ module Cased
144
152
  @command = session.fetch('command')
145
153
  @metadata = session.fetch('metadata')
146
154
  @reason = session.fetch('reason')
155
+ @forwarded_ip_address = session.fetch('forwarded_ip_address')
147
156
  @ip_address = session.fetch('ip_address')
148
157
  @requester = session.fetch('requester')
149
158
  @responded_at = session['responded_at']
@@ -226,6 +235,7 @@ module Cased
226
235
 
227
236
  response = Cased.clients.cli.post('cli/sessions',
228
237
  user_token: authentication.token,
238
+ forwarded_ip_address: forwarded_ip_address,
229
239
  reason: reason,
230
240
  metadata: metadata,
231
241
  command: command)
data/lib/cased/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cased
4
- VERSION = '0.4.3'
4
+ VERSION = '0.4.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cased-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Bjerkhoel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport