killbill-aviate 1.1.0.pre.8 → 1.1.0.pre.9

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: 5c9a61754eb5cdc016175eff105c47d1880d215296a2610a2565e5f9c790342e
4
- data.tar.gz: 0e4065fb702a9081639dc3b4ca3f6e0ad08623c4ed43e76cd0bb141793df29fa
3
+ metadata.gz: ea3985ee1127fe9cbbc0a1896232e62c30141e42d473124a6e7e90a14fc00e95
4
+ data.tar.gz: ed28ef7bfc826edfaa466507a8420e881643d80c8a87b300d77c9245271f836c
5
5
  SHA512:
6
- metadata.gz: 36f92def06ac140459a9da79c6bb184aa5c0c474377c75a24ddbfb65a3c136f3b7f794c239a0f2ffa02c6c8c53468780d9f9df6c0fe61b90e9d92b09c58b0b5a
7
- data.tar.gz: 1e361ade02913a25f54f949490f5b31f901223307bc12deeff2044a5d2369fa541ea60df7a06b501f21074caf49b303940b2f0b716424a2d70b796bd3b9ebb5f
6
+ metadata.gz: 11f19b4f4d638a8ab19a2bdf37a047d3c5e0ad6f961bf3bcf820cde4b659e1602cd128c4d0783a35ffea9d8b743bdd64f530ea1f4d01c5850ca585f7bcd166bb
7
+ data.tar.gz: bdb605b58476704ab73016eb59588f880376a97803b56ad8c0379e029c74bd87b9d5895ce6321e20445a57271d53f190b231bea92d2811b10abe7a1be3783d02
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'aviate/client'
4
- require 'securerandom'
5
4
 
6
5
  module Aviate
7
6
  class ConfigurationController < Aviate::EngineController
@@ -16,11 +15,14 @@ module Aviate
16
15
  response = Killbill::Aviate::AviateClient.authenticate(email, password, cached_options_for_klient)
17
16
 
18
17
  if response.is_a?(Hash) && response['token']
19
- reference_token = SecureRandom.hex(16)
20
- session[:aviate_token_ref] = reference_token
21
-
22
- # Store actual JWT in Rails cache using the reference token
23
- Rails.cache.write("aviate_jwt_#{reference_token}", response['token'], expires_in: 1.hour)
18
+ # Store JWT in encrypted cookie
19
+ cookies.encrypted[:jwt_token] = {
20
+ value: response['token'],
21
+ httponly: true,
22
+ secure: Rails.env.production?,
23
+ same_site: :strict,
24
+ expires: 1.hour.from_now
25
+ }
24
26
  flash[:notice] = t('aviate.configuration.authentication_success')
25
27
  else
26
28
  flash[:error] = t('aviate.configuration.authentication_failed')
@@ -30,11 +32,12 @@ module Aviate
30
32
  end
31
33
 
32
34
  def session_destroy
33
- if session[:aviate_token_ref].present?
34
- jwt_cache_key = "aviate_jwt_#{session[:aviate_token_ref]}"
35
- Rails.cache.delete(jwt_cache_key)
36
- session.delete(:aviate_token_ref)
37
- end
35
+ # Delete JWT cookie
36
+ cookies.delete(:jwt_token)
37
+
38
+ # Clean up any existing session references
39
+ session.delete(:aviate_token_ref)
40
+
38
41
  flash[:notice] = t('aviate.configuration.logout_success')
39
42
  redirect_to aviate_root_path
40
43
  end
@@ -63,5 +63,19 @@ module Aviate
63
63
  flash[:error] = t('flashes.errors.wallet_authentication_failed')
64
64
  redirect_to aviate_engine.aviate_root_path
65
65
  end
66
+
67
+ private
68
+
69
+ def options_for_klient
70
+ # Get the base options from parent class
71
+ base_options = super
72
+
73
+ # Add JWT token from cookies if available
74
+ if cookies.encrypted[:jwt_token].present?
75
+ base_options.merge(jwt_token: cookies.encrypted[:jwt_token])
76
+ else
77
+ base_options
78
+ end
79
+ end
66
80
  end
67
81
  end
@@ -15,9 +15,12 @@
15
15
  </div>
16
16
  <div class="d-flex justify-content-end">
17
17
  <%= link_to "Logout", aviate_session_destroy_path,
18
- method: :delete,
19
- class: "btn btn-outline-secondary",
20
- confirm: "Are you sure you want to logout from Aviate?" %>
18
+ class: "btn btn-outline-secondary",
19
+ data: {
20
+ turbo_method: :delete,
21
+ turbo_confirm: "Are you sure you want to logout from Aviate?"
22
+ }
23
+ %>
21
24
  </div>
22
25
  <% else %>
23
26
  <div class="configuration-form">
@@ -106,8 +106,6 @@ window.addEventListener('load', function() {
106
106
  return;
107
107
  }
108
108
  this.focus();
109
- this.type = 'text';
110
- this.type = 'date';
111
109
  });
112
110
  });
113
111
  <% end %>
data/config/routes.rb CHANGED
@@ -5,7 +5,7 @@ Aviate::Engine.routes.draw do
5
5
 
6
6
  scope '/configuration' do
7
7
  match '/session_create' => 'configuration#session_create', :via => :post, :as => 'aviate_session_create'
8
- match '/session_destroy' => 'configuration#session_destroy', :via => :delete, :as => 'aviate_session_destroy'
8
+ match '/session_destroy' => 'configuration#session_destroy', :via => [:get, :delete], :as => 'aviate_session_destroy'
9
9
  end
10
10
 
11
11
  resources :accounts, param: :account_id do
data/lib/aviate/client.rb CHANGED
@@ -90,8 +90,8 @@ module Killbill
90
90
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
91
91
  request = Net::HTTP::Post.new(uri.path)
92
92
  request['Content-Type'] = 'application/json'
93
- request['X-Killbill-ApiKey'] = options[:api_key]
94
- request['X-Killbill-ApiSecret'] = options[:api_secret]
93
+ request['X-Killbill-ApiKey'] = options&.dig(:api_key)
94
+ request['X-Killbill-ApiSecret'] = options&.dig(:api_secret)
95
95
  request['Authorization'] = "Basic #{auth}"
96
96
  request.body = {}.to_json
97
97
  response = http.request(request)
@@ -103,6 +103,8 @@ module Killbill
103
103
  private
104
104
 
105
105
  def build_request_options(options)
106
+ return {} if options.nil?
107
+
106
108
  request_options = {
107
109
  api_key: options[:api_key],
108
110
  api_secret: options[:api_secret]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aviate
4
- VERSION = '1.1.0.pre.8'
4
+ VERSION = '1.1.0.pre.9'
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.8
4
+ version: 1.1.0.pre.9
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-11-01 00:00:00.000000000 Z
11
+ date: 2025-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: killbill-assets-ui