killbill-aviate 1.1.0.pre.1 → 1.1.0.pre.3

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: 89879b3fdf628ffa251342e2854f21eb8c8f3b6c738a4d5404bb3f064c4e5275
4
- data.tar.gz: 46977fab39f39d8737d4a611b4acd9e8be807bdf6c64b202d86dd68df2a5c690
3
+ metadata.gz: c319f915aef12e37c59e9da46e0c1435109580df42f47e0405fe3892e925b8d9
4
+ data.tar.gz: fc4f02d1810b40db9538cf72aeddb04126f4e826dcc198cfe35c02ebc2dfd2e2
5
5
  SHA512:
6
- metadata.gz: e575203964276a13d2e1453211524a413e3176fa926c0a90d23b1005f92ad19a112bcd965f4da776818b174e989f067e0ec59e4db6a4767dbffa65154194a5dc
7
- data.tar.gz: ba5e453cf98615607bfce226040827a511e3c7528de4826ccf0d0749fa8b3ae34a21163aeac995d4af22922023d29ba3859f298427822ffd511b3d97c57ffe00
6
+ metadata.gz: 1b7db95a97a8052deb9032ba38b7024ec12139a533b56dd17571e0b4b44df5af1925db587d190d7fd500c9870b1278fe4c8b6c9525b814b1bd0c12dab278ab5b
7
+ data.tar.gz: 6cdb61d694a1b52ff3f245c1bfb1d6e52c9a34c0ec87e540fc122be2dc3811d820c218fd311dbec90b7309ef06ac86f28c9b121c4370c4d04c21c9a4811b818e
@@ -12,7 +12,15 @@ module Aviate
12
12
  email = params[:aviate_email]
13
13
  password = params[:aviate_password]
14
14
  response = Killbill::Aviate::AviateClient.authenticate(email, password, cached_options_for_klient)
15
- session[:jwt_token] = response['token'] if response['token']
15
+ if response['token']
16
+ cookies.encrypted[:jwt_token] = {
17
+ value: response['token'],
18
+ httponly: true,
19
+ secure: Rails.env.production?,
20
+ same_site: :strict,
21
+ expires: 1.hour.from_now
22
+ }
23
+ end
16
24
  redirect_to aviate_root_path
17
25
  end
18
26
  end
data/lib/aviate/client.rb CHANGED
@@ -8,7 +8,10 @@ module Killbill
8
8
  class << self
9
9
  def aviate_plugin_available?(options = nil)
10
10
  path = "#{KILLBILL_AVIATE_PREFIX}/health/data"
11
- KillBillClient::API.get path, {}, get_token(options)
11
+
12
+ request_options = build_request_options(options)
13
+
14
+ KillBillClient::API.get path, {}, request_options
12
15
 
13
16
  [true, nil]
14
17
  rescue KillBillClient::API::ResponseError => e
@@ -28,7 +31,10 @@ module Killbill
28
31
 
29
32
  def retrieve_wallets(account_id, options = nil)
30
33
  path = "#{KILLBILL_AVIATE_PREFIX}/wallet/#{account_id}"
31
- response = KillBillClient::API.get path, {}, get_token(options)
34
+
35
+ request_options = build_request_options(options)
36
+
37
+ response = KillBillClient::API.get path, {}, request_options
32
38
  JSON.parse(response.body)
33
39
  end
34
40
 
@@ -41,7 +47,10 @@ module Killbill
41
47
  expDurationUnit: wallet_params[:exp_duration_unit],
42
48
  expDurationLength: wallet_params[:exp_duration_length]
43
49
  }
44
- response = KillBillClient::API.put path, body.to_json, {}, get_token(options)
50
+
51
+ request_options = build_request_options(options)
52
+
53
+ response = KillBillClient::API.put path, body.to_json, {}, request_options
45
54
  response.code
46
55
  end
47
56
 
@@ -64,7 +73,9 @@ module Killbill
64
73
  }
65
74
  }
66
75
 
67
- response = KillBillClient::API.post path, body.to_json, {}, get_token(options)
76
+ request_options = build_request_options(options)
77
+
78
+ response = KillBillClient::API.post path, body.to_json, {}, request_options
68
79
  JSON.parse(response.body)
69
80
  rescue StandardError => e
70
81
  JSON.parse(e.message)
@@ -77,11 +88,12 @@ module Killbill
77
88
  base_url = KillBillClient::API.base_uri
78
89
  uri = URI("#{base_url}#{path}")
79
90
  http = Net::HTTP.new(uri.host, uri.port)
80
-
91
+ http.use_ssl = (uri.scheme == 'https')
92
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
81
93
  request = Net::HTTP::Post.new(uri.path)
82
94
  request['Content-Type'] = 'application/json'
83
- request['X-killbill-apiKey'] = options[:api_key]
84
- request['X-killbill-apisecret'] = options[:api_secret]
95
+ request['X-Killbill-ApiKey'] = options[:api_key]
96
+ request['X-Killbill-ApiSecret'] = options[:api_secret]
85
97
  request['Authorization'] = "Basic #{auth}"
86
98
  request.body = {}.to_json
87
99
  response = http.request(request)
@@ -92,11 +104,17 @@ module Killbill
92
104
 
93
105
  private
94
106
 
95
- def get_token(options = nil)
96
- {
107
+ def build_request_options(options)
108
+ request_options = {
97
109
  api_key: options[:api_key],
98
110
  api_secret: options[:api_secret]
99
- }.merge({ bearer: options[:jwt_token].to_s })
111
+ }
112
+
113
+ if options[:jwt_token].present?
114
+ request_options[:head] = { 'Authorization' => "Bearer #{options[:jwt_token]}" }
115
+ end
116
+
117
+ request_options
100
118
  end
101
119
  end
102
120
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aviate
4
- VERSION = '1.1.0.pre.1'
4
+ VERSION = '1.1.0.pre.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-aviate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre.1
4
+ version: 1.1.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-13 00:00:00.000000000 Z
11
+ date: 2025-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: killbill-assets-ui