kaui 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -2
  4. data/Gemfile.lock +59 -38
  5. data/README.md +12 -9
  6. data/Rakefile +9 -0
  7. data/{lib/generators/kaui/install/templates/app/assets/javascripts/kaui/all.js → app/assets/javascripts/application.js} +2 -5
  8. data/{lib/generators/kaui/install/templates/app/assets/stylesheets/kaui/all.css → app/assets/stylesheets/application.css} +0 -4
  9. data/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
  10. data/app/controllers/kaui/admin_allowed_users_controller.rb +48 -0
  11. data/app/controllers/kaui/admin_tenants_controller.rb +97 -0
  12. data/app/controllers/kaui/engine_controller.rb +28 -31
  13. data/app/controllers/kaui/engine_controller_util.rb +33 -0
  14. data/app/controllers/kaui/login_proxy_controller.rb +11 -0
  15. data/app/controllers/kaui/sessions_controller.rb +12 -0
  16. data/app/controllers/kaui/tenants_controller.rb +60 -0
  17. data/app/models/kaui/ability.rb +20 -3
  18. data/app/models/kaui/admin_tenant.rb +10 -0
  19. data/app/models/kaui/allowed_user.rb +8 -0
  20. data/app/models/kaui/allowed_user_tenant.rb +6 -0
  21. data/app/models/kaui/killbill_authenticatable.rb +5 -18
  22. data/app/models/kaui/tenant.rb +13 -0
  23. data/app/models/kaui/user.rb +14 -16
  24. data/app/views/kaui/admin_allowed_users/index.html.erb +23 -0
  25. data/app/views/kaui/admin_allowed_users/new.html.erb +22 -0
  26. data/app/views/kaui/admin_allowed_users/show.html.erb +53 -0
  27. data/app/views/kaui/admin_tenants/index.html.erb +25 -0
  28. data/app/views/kaui/admin_tenants/new.html.erb +32 -0
  29. data/app/views/kaui/admin_tenants/show.html.erb +68 -0
  30. data/app/views/kaui/invoices/show.html.erb +1 -1
  31. data/app/views/kaui/tenants/index.html.erb +17 -0
  32. data/config/initializers/killbill_authenticatable.rb +3 -5
  33. data/config/locales/en.bootstrap.yml +18 -0
  34. data/config/routes.rb +27 -1
  35. data/config/symmetric-encryption.yml +135 -0
  36. data/db/ddl.sql +33 -2
  37. data/db/migrate/20130812155313_devise_create_kaui_users.rb +1 -3
  38. data/db/migrate/20150109214021_create_kaui_tenants.rb +12 -0
  39. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +19 -0
  40. data/kaui.gemspec +5 -3
  41. data/lib/kaui.rb +49 -1
  42. data/lib/kaui/version.rb +1 -1
  43. data/test/dummy/config/application.rb +3 -0
  44. data/test/dummy/config/database.yml +9 -0
  45. data/test/dummy/config/environments/development.rb +2 -2
  46. data/test/dummy/config/initializers/killbill_client.rb +2 -0
  47. data/test/dummy/config/symmetric-encryption.yml +135 -0
  48. data/test/dummy/db/migrate/{20130819152643_devise_create_kaui_users.kaui.rb → 20150116052157_devise_create_kaui_users.kaui.rb} +1 -3
  49. data/test/dummy/db/migrate/20150116052158_create_kaui_tenants.kaui.rb +13 -0
  50. data/test/dummy/db/migrate/20150116052159_create_kaui_allowed_users.kaui.rb +20 -0
  51. data/test/dummy/db/schema.rb +29 -3
  52. data/test/functional/kaui/admin_allowed_users_controller_test.rb +30 -0
  53. data/test/functional/kaui/admin_tenants_controller_test.rb +35 -0
  54. data/test/functional/kaui/functional_test_helper.rb +2 -50
  55. data/test/functional/kaui/functional_test_helper_nosetup.rb +53 -0
  56. data/test/functional/kaui/invoices_controller_test.rb +22 -0
  57. data/test/functional/kaui/tenants_controller_test.rb +60 -0
  58. data/test/integration/kaui/integration_test_helper.rb +2 -0
  59. data/test/integration/kaui/navigation_test.rb +1 -2
  60. data/test/killbill_test_helper.rb +46 -4
  61. data/test/test_helper.rb +1 -0
  62. data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +6 -0
  63. data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +6 -0
  64. data/test/unit/helpers/kaui/tenants_helper_test.rb +6 -0
  65. data/test/unit/kaui/allowed_user_test.rb +34 -0
  66. data/test/unit/kaui/tenant_test.rb +19 -0
  67. data/vendor/assets/javascripts/jquery.dataTables.min.js +155 -0
  68. metadata +86 -21
  69. data/app/assets/javascripts/kaui/analytics.js +0 -71
  70. data/app/assets/stylesheets/kaui/analytics.css +0 -30
  71. data/test/dummy/app/assets/javascripts/application.js +0 -21
  72. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  73. data/test/dummy/app/views/layouts/application.html.erb +0 -48
  74. data/vendor/assets/javascripts/js/bootstrap-datepicker.cd46d38.js +0 -1211
  75. data/vendor/assets/javascripts/js/bootstrap.v2.2.1.min.js +0 -6
  76. data/vendor/assets/javascripts/js/jquery.dataTables.v1.9.3.min.js +0 -156
@@ -0,0 +1,25 @@
1
+ <% if can? :view, Kaui::AdminTenant %>
2
+ <% unless @tenants.empty? %>
3
+ <table id="tenants-table" class="table table-condensed">
4
+ <thead>
5
+ <tr>
6
+ <th>Name</th>
7
+ <th>Tenant Id</th>
8
+ <th>Api Key</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @tenants.each do |t| %>
13
+ <tr>
14
+ <td><%= link_to t.name, admin_tenant_path(t.id) %></td>
15
+ <td><%= t.kb_tenant_id %></td>
16
+ <td><%= t.api_key %></td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+ <% end %>
22
+ <% end %>
23
+ <% if can? :create, Kaui::AdminTenant %>
24
+ <h3><%= link_to 'Configure a New Tenant', new_admin_tenant_path %></h3>
25
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <% if can? :create, Kaui::AdminTenant %>
2
+ <%= form_for @tenant, url: admin_tenants_path, :html => {:class => 'form-horizontal'} do |f| %>
3
+ <fieldset>
4
+
5
+ <div class="control-group">
6
+ <%= f.label :name, 'Name', :class => 'control-label' %>
7
+ <div class="controls">
8
+ <%= f.text_field :name, :class => 'input-small', :required => true %>
9
+ </div>
10
+ </div>
11
+
12
+
13
+ <div class="control-group">
14
+ <%= f.label :api_key, 'API Key', :class => 'control-label' %>
15
+ <div class="controls">
16
+ <%= f.text_field :api_key, :class => 'input-small', :required => true %>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="control-group">
21
+ <%= f.label :api_secret, 'API Secret', :class => 'control-label' %>
22
+ <div class="controls">
23
+ <%= f.password_field :api_secret, :class => 'input-small', :required => true %>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="form-actions">
28
+ <%= button_tag 'Configure a new Tenant', :class => 'btn btn-primary' %>
29
+ </div>
30
+ </fieldset>
31
+ <% end %>
32
+ <% end %>
@@ -0,0 +1,68 @@
1
+ <% if can? :view, Kaui::AdminTenant %>
2
+ <dl class="dl-horizontal">
3
+ <dt>Name:</dt>
4
+ <dd><%= @tenant.name %>&nbsp;</dd>
5
+ <dt>Tenant ID:</dt>
6
+ <dd><%= @tenant.kb_tenant_id %>&nbsp;</dd>
7
+ <dt>API Key:</dt>
8
+ <dd><%= @tenant.api_key %>&nbsp;</dd>
9
+ </dl>
10
+
11
+ <% unless @tenant.kaui_allowed_users.empty? %>
12
+ <h3>Allowed Users:</h3>
13
+ <table id="allowed-users-for-tenant-table" class="table table-condensed">
14
+ <thead>
15
+ <tr>
16
+ <th>Name</th>
17
+ <th>Description</th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <% @tenant.kaui_allowed_users.each do |u| %>
22
+ <tr>
23
+ <td><%= link_to u.kb_username, admin_allowed_user_path(u.id) %></td>
24
+ <td><%= u.description %></td>
25
+ <td>
26
+ <button type="button" class="btn btn-default btn-sm" id="<%= "allowed-user-remove-#{u.id}" %>">
27
+ <span class="icon-remove"></span>
28
+ </button>
29
+ </td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+ <% end %>
35
+ <% end %>
36
+ <% if can? :config_upload, Kaui::AdminTenant %>
37
+ <%= form_tag({action: :upload_catalog}, method: 'post', multipart: true) do %>
38
+
39
+ <%= hidden_field_tag(:id, @tenant.id) %>
40
+
41
+ <div class="control-group">
42
+ <%= label_tag :catalog, 'Tenant Catalog XML', :class => 'control-label' %>
43
+ <div class="controls">
44
+ <%= file_field_tag 'catalog' %>
45
+ </div>
46
+ </div>
47
+ <div class="actions">
48
+ <%= submit_tag 'Upload' %>
49
+ </div>
50
+ <% end %>
51
+ <div class="form-actions">
52
+ <%= link_to 'Back', :back, :class => 'btn' %>
53
+ </div>
54
+ <% end %>
55
+
56
+ <%= javascript_tag do %>
57
+ $(document).ready(function() {
58
+ $('[id^=allowed-user-remove-]').click(function() {
59
+ var allowedUser = $(this);
60
+ $.ajax({ type: "DELETE",
61
+ url: "<%= remove_allowed_user_path :format => :json %>",
62
+ data: { allowed_user: { id: this['id'].split('-')[3] }, id: <%= @tenant.id %>},
63
+ success: function(data) { allowedUser.parent().parent().hide(); return false; },
64
+ error: function(request, textStatus, errorThrown) { console.log("AJAX FAILED!!!! request.status " + request.status + ", textStatus = " + textStatus); return false; }
65
+ });
66
+ });
67
+ });
68
+ <% end %>
@@ -57,7 +57,7 @@
57
57
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.description %></td>
58
58
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.start_date.html_safe if item.start_date %></td>
59
59
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.end_date.html_safe if item.end_date %></td>
60
- <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(sub.charged_through_date, @account.timezone).html_safe if sub.present? %></td>
60
+ <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(sub.charged_through_date, @account.time_zone).html_safe if sub.present? %></td>
61
61
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= sub.price_list.downcase.capitalize if sub.present? and sub.price_list.present? %></td>
62
62
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= humanized_money_with_symbol Kaui::InvoiceItem.amount_to_money(item) %> (<%= item.currency %>)</td>
63
63
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.audit_logs.map {|log| log.comments}.compact.join('<br/>') if item.audit_logs.present? %></td>
@@ -0,0 +1,17 @@
1
+ <% unless @tenants.empty? %>
2
+ <%= form_for(@tenants, :url => {:action => :select_tenant}, :html => {:method => :post, :class => "form-horizontal"}) do |f| %>
3
+ <fieldset>
4
+ <div class="control-group">
5
+ <%= label_tag :tenant_name, "Available Tenants:", :class => "control-label" %>
6
+ <div class="controls">
7
+ <%= select_tag :kb_tenant_id, options_for_select(@tenants.map { |t| [t.name, t.kb_tenant_id] }) %>
8
+ </div>
9
+ </div>
10
+ <div class="form-actions">
11
+ <%= f.submit 'Chose Tenant', :class => 'btn btn-primary' %>
12
+ <%= link_to 'Back', :back, :class => 'btn' %>
13
+ </div>
14
+
15
+ </fieldset>
16
+ <% end %>
17
+ <% end %>
@@ -5,18 +5,16 @@ module Devise
5
5
  class KillbillAuthenticatable < Authenticatable
6
6
  # Invoked by warden to execute the strategy
7
7
  def authenticate!
8
+
8
9
  creds = params[:user] || {}
9
10
  kb_username = creds[:kb_username]
10
11
  kb_password = password
11
- api_key = creds[:api_key] || KillBillClient.api_key
12
- api_secret = creds[:api_password] || KillBillClient.api_secret
13
-
14
12
  # Find the associated user object
15
- resource = valid_password? && mapping.to.find_for_killbill_authentication(kb_username, kb_password, api_key, api_secret)
13
+ resource = valid_password? && mapping.to.find_for_killbill_authentication(kb_username)
16
14
  return fail(:not_found_in_database) unless resource
17
15
 
18
16
  # Validate the credentials
19
- if validate(resource){ resource.valid_killbill_password?(kb_username, kb_password, api_key, api_secret) }
17
+ if validate(resource){ resource.valid_killbill_password?(kb_username, kb_password) }
20
18
  # Create the user if needed
21
19
  resource.after_killbill_authentication
22
20
  # Tell warden to halt the strategy and set the user in the appropriate scope
@@ -0,0 +1,18 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ helpers:
6
+ actions: "Actions"
7
+ links:
8
+ back: "Back"
9
+ cancel: "Cancel"
10
+ confirm: "Are you sure?"
11
+ destroy: "Delete"
12
+ new: "New"
13
+ edit: "Edit"
14
+ titles:
15
+ edit: "Edit %{model}"
16
+ save: "Save %{model}"
17
+ new: "New %{model}"
18
+ delete: "Delete %{model}"
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  Kaui::Engine.routes.draw do
2
+
2
3
  devise_for :users,
3
4
  :class_name => 'Kaui::User',
4
5
  :module => :devise,
5
- :controllers => { :sessions => 'kaui/sessions' }
6
+ :controllers => { :sessions => 'kaui/sessions'}
6
7
 
7
8
  resources :tag_definitions
8
9
 
@@ -103,5 +104,30 @@ Kaui::Engine.routes.draw do
103
104
  scope "/custom_fields" do
104
105
  match "/pagination" => "custom_fields#pagination", :via => :get, :as => "custom_fields_pagination"
105
106
  end
107
+
108
+ scope "/tenants" do
109
+ match "/" => "tenants#index", :via => :get, :as => "tenants"
110
+ match "/select_tenant" => "tenants#select_tenant", :via => :post, :as => "select_tenant"
111
+ end
112
+
113
+ scope "/login_proxy" do
114
+ match "/check_login" => "login_proxy#check_login", :via => :get, :as => "check_login"
115
+ end
116
+
117
+ scope "/home" do
118
+ match "/" => "home#index", :via => :get, :as => "home"
119
+ end
120
+
121
+ resources :admin_tenants, :only => [ :index, :new, :create, :show ]
122
+ scope "/admin_tenants" do
123
+ match "/upload_catalog" => "admin_tenants#upload_catalog", :via => :post, :as => "admin_tenant_upload_catalog"
124
+ match "/remove_allowed_user" => "admin_tenants#remove_allowed_user", :via => :delete, :as => "remove_allowed_user"
125
+ end
126
+
127
+ resources :admin_allowed_users, :only => [ :index, :new, :create, :show ]
128
+ scope "/admin_allowed_users" do
129
+ match "/add_tenant" => "admin_allowed_users#add_tenant", :via => :post, :as => "add_tenant"
130
+ end
131
+
106
132
  resources :custom_fields, :only => [ :create, :new, :index, :show ]
107
133
  end
@@ -0,0 +1,135 @@
1
+ #
2
+ # Symmetric Encryption for Ruby
3
+ #
4
+ ---
5
+ # For the development and test environments the test symmetric encryption keys
6
+ # can be placed directly in the source code.
7
+ # And therefore no RSA private key is required
8
+ development: &development_defaults
9
+ key: 1234567890ABCDEF1234567890ABCDEF
10
+ iv: 1234567890ABCDEF
11
+ cipher_name: aes-128-cbc
12
+ encoding: :base64strict
13
+ private_rsa_key: |
14
+ -----BEGIN RSA PRIVATE KEY-----
15
+ MIIEpAIBAAKCAQEAxfbNAn6fc+poM/5mZwpDqO/fD064jcb5HNnCMm0AgXE75nU4
16
+ J2zrDbLj9bmKTHNdhYiwTCPsnZ9Ngtz4VmBRHkmirA6cclMesWXUHlqfHyCvvEYj
17
+ bhVMwOu/t07wPzFH7/f2HQLEX4IlwyNvJyq+AMLHVRCbMMfYCUDIEhUlsGxKQryq
18
+ yk+ga24EMPBLdSf1g1oas9dy7qDtK+91Bh1k7Oo7CrkisRQ70t1Cz+paQSJVZXxv
19
+ MBP6B8eXReB9YLOaIdsKoqEZ6Z0SEFr3xxudiB4ReYB9qqKeTDV0/VLf2m6TmnUr
20
+ ZImLJbi/bAxbcU3h9J4sq5Ma+l1t0gsmO0mlbQIDAQABAoIBAAU5AqWbM5e6Sm98
21
+ ubTkN27AjVD5EbNj2XSiZhYwe//uPddRpl6b6AOfgZYdBAIKVSBNv+DyXa624jOe
22
+ osqcledHqAwEAqqdeMTTW+pFF8eZdClybELeOv0n+xHZ+kqggTZag1q2lPm0FEz2
23
+ pVsSLJsWiG29F2sNCq0L0XtwpWLnHJO0U0dUjVtspDpAnQkl+l8WiTJkY0uf+L8z
24
+ iY6VDtNhf+Cc2TyOnB51nArHQfVt6pSahn8UB7gnjoPBjEPSlSj68XwjNLViFj94
25
+ NeXdrOQ/kjlsJcuX06jfUulHOlFP+uOft3m/q+8OC0uQm4EmcJ9p+m8E6z5ypUDp
26
+ kHi7swECgYEA74mktO2725fON43HpHG/fNglTPqlDUdoqUlDg7ovaDiaL+FlnhOb
27
+ 7vUBfJ5FjWkeO6Teg0ElOA03sOAq29ql91kaweSEbSkRb5HLVGo7m3FTKfi8rTpe
28
+ QufQDjt8kvnAtNSlXQexG3BJpondbMF4hYZSTtGPjkM0MQOqkByUZC0CgYEA05G5
29
+ M/NnZXpXvpZNCHlDht98bHUAZfKLRe7FTAqLBWAEWG70x8aBhzFn6kOD0jhsVcnt
30
+ 3EwiUD1MIuiWYvyGmwBoRCQGVxW2LuxbBYRSpPgTPKPM9juc3GYs36KTSbA3+44y
31
+ 2Fys8/gQusYQ3YwomxU4ygL5lyxxY14sQ3UAzkECgYEAhjRJ8YyYicmdogZvajTI
32
+ oju/ekebnbr6ao4/o1f3I59C07ym4FAAN3tRn+5U7YuNgsE2YbdoEOVm5FRT7uWr
33
+ ws9LbIKJp1cxC59VmjACwW5Wt9dCbpObKEUUjkTJ4NbJHwdctqiOk97vhL0NL9ed
34
+ nMHK75n9oikI3sU9FIzOnukCgYEAz9FpgZ1K6EQ3om9S9crfyMEIICUBoiKQKb5z
35
+ sND+Y+Y//nnnGcFkhF7EezmcZ8eiqtYyPl3OqtC7U+LxrgPtWJ4azSwxyiL6lLb4
36
+ Zb/nykIf60Xe09QUre3zkCzKzuw44XF5gkvuW6tFC6H4+RZu4H8FDHHFp3gxXPEp
37
+ O43Xn8ECgYBzM7yEM0SUE6DI0WGATtuhVRXL3hjgPqf3TzmsQFMEal2Bu14d/d9f
38
+ zLks8POWjtQcgn2PGvrHS+aJZYR0okue4Ny5bfk+AohClXDtqZnz45wabYrRq6Xg
39
+ dTi8xJJHVkoRfcQleui6oqRB3i4iGlu5k8T1+djLLiN9eo0PY1VciQ==
40
+ -----END RSA PRIVATE KEY-----
41
+
42
+ test:
43
+ <<: *development_defaults
44
+
45
+ release:
46
+ # Since the key to encrypt and decrypt with must NOT be stored along with the
47
+ # source code, we only hold a RSA key that is used to unlock the file
48
+ # containing the actual symmetric encryption key
49
+ private_rsa_key: |
50
+ -----BEGIN RSA PRIVATE KEY-----
51
+ MIIEpAIBAAKCAQEAxfbNAn6fc+poM/5mZwpDqO/fD064jcb5HNnCMm0AgXE75nU4
52
+ J2zrDbLj9bmKTHNdhYiwTCPsnZ9Ngtz4VmBRHkmirA6cclMesWXUHlqfHyCvvEYj
53
+ bhVMwOu/t07wPzFH7/f2HQLEX4IlwyNvJyq+AMLHVRCbMMfYCUDIEhUlsGxKQryq
54
+ yk+ga24EMPBLdSf1g1oas9dy7qDtK+91Bh1k7Oo7CrkisRQ70t1Cz+paQSJVZXxv
55
+ MBP6B8eXReB9YLOaIdsKoqEZ6Z0SEFr3xxudiB4ReYB9qqKeTDV0/VLf2m6TmnUr
56
+ ZImLJbi/bAxbcU3h9J4sq5Ma+l1t0gsmO0mlbQIDAQABAoIBAAU5AqWbM5e6Sm98
57
+ ubTkN27AjVD5EbNj2XSiZhYwe//uPddRpl6b6AOfgZYdBAIKVSBNv+DyXa624jOe
58
+ osqcledHqAwEAqqdeMTTW+pFF8eZdClybELeOv0n+xHZ+kqggTZag1q2lPm0FEz2
59
+ pVsSLJsWiG29F2sNCq0L0XtwpWLnHJO0U0dUjVtspDpAnQkl+l8WiTJkY0uf+L8z
60
+ iY6VDtNhf+Cc2TyOnB51nArHQfVt6pSahn8UB7gnjoPBjEPSlSj68XwjNLViFj94
61
+ NeXdrOQ/kjlsJcuX06jfUulHOlFP+uOft3m/q+8OC0uQm4EmcJ9p+m8E6z5ypUDp
62
+ kHi7swECgYEA74mktO2725fON43HpHG/fNglTPqlDUdoqUlDg7ovaDiaL+FlnhOb
63
+ 7vUBfJ5FjWkeO6Teg0ElOA03sOAq29ql91kaweSEbSkRb5HLVGo7m3FTKfi8rTpe
64
+ QufQDjt8kvnAtNSlXQexG3BJpondbMF4hYZSTtGPjkM0MQOqkByUZC0CgYEA05G5
65
+ M/NnZXpXvpZNCHlDht98bHUAZfKLRe7FTAqLBWAEWG70x8aBhzFn6kOD0jhsVcnt
66
+ 3EwiUD1MIuiWYvyGmwBoRCQGVxW2LuxbBYRSpPgTPKPM9juc3GYs36KTSbA3+44y
67
+ 2Fys8/gQusYQ3YwomxU4ygL5lyxxY14sQ3UAzkECgYEAhjRJ8YyYicmdogZvajTI
68
+ oju/ekebnbr6ao4/o1f3I59C07ym4FAAN3tRn+5U7YuNgsE2YbdoEOVm5FRT7uWr
69
+ ws9LbIKJp1cxC59VmjACwW5Wt9dCbpObKEUUjkTJ4NbJHwdctqiOk97vhL0NL9ed
70
+ nMHK75n9oikI3sU9FIzOnukCgYEAz9FpgZ1K6EQ3om9S9crfyMEIICUBoiKQKb5z
71
+ sND+Y+Y//nnnGcFkhF7EezmcZ8eiqtYyPl3OqtC7U+LxrgPtWJ4azSwxyiL6lLb4
72
+ Zb/nykIf60Xe09QUre3zkCzKzuw44XF5gkvuW6tFC6H4+RZu4H8FDHHFp3gxXPEp
73
+ O43Xn8ECgYBzM7yEM0SUE6DI0WGATtuhVRXL3hjgPqf3TzmsQFMEal2Bu14d/d9f
74
+ zLks8POWjtQcgn2PGvrHS+aJZYR0okue4Ny5bfk+AohClXDtqZnz45wabYrRq6Xg
75
+ dTi8xJJHVkoRfcQleui6oqRB3i4iGlu5k8T1+djLLiN9eo0PY1VciQ==
76
+ -----END RSA PRIVATE KEY-----
77
+
78
+
79
+ # List Symmetric Key files in the order of current / latest first
80
+ ciphers:
81
+ -
82
+ # Filename containing Symmetric Encryption Key encrypted using the
83
+ # RSA public key derived from the private key above
84
+ key_filename: config/keys/dummy_release.key
85
+ iv_filename: config/keys/dummy_release.iv
86
+ cipher_name: aes-256-cbc
87
+ # Base64 encode encrypted data without newlines
88
+ encoding: :base64strict
89
+ version: 1
90
+
91
+ production:
92
+ # Since the key to encrypt and decrypt with must NOT be stored along with the
93
+ # source code, we only hold a RSA key that is used to unlock the file
94
+ # containing the actual symmetric encryption key
95
+ private_rsa_key: |
96
+ -----BEGIN RSA PRIVATE KEY-----
97
+ MIIEpAIBAAKCAQEAy6UmlgZFM2f70i5/xINHdxZVbxPRgUrfO643LGUC1gfZVsNn
98
+ kus5xoAjZKgdlS2o47X8PYFi8gR96NBWPAQYS9M3p6KDbs9Yt+Imcb0LeHCamMin
99
+ AvhE5QBlf+A13oYY5xOTrwJMq1hSGB8rC3gbZMgSJBbjAiW+zgwzLzjXaphTwulP
100
+ 8/Ht9PucvZE8arxsmvi7dGXr5B3uDZjAeS9qCl9LOMwHtOLeKD8GvKniN0tLUaSA
101
+ SWgI3z46KonSiYelzAMdhkwP4K5SqUITp9Uv7SVCoPoM7Xm640BnD0MJWxKH6lVi
102
+ 56YJnT5xuIDC4zGwGdZG4dJS0ep1uSX0ZQ2xhwIDAQABAoIBAQCgn8brlk6G2YG6
103
+ qoqEibeYqrkAP/WDsXaaMDO8hH/UKaS31rCfJYIQm4lPH3sV60nHMgeey6srkXdu
104
+ ZsVd2S0AwbyoMHrSsCEeCPahx6aAfPCzibCRmxlcNw/X6RUUS1jhCoP2Ci5HCAbY
105
+ l9zv0vBocZY9eP/c9cCl7OGCYacnn0zZNf8dRZ6qPkOA8ySejPbgzmhQTt1JAJUw
106
+ 2HaWo0tyCu0cE6FL//b+a+gblLc0e/2Y45BSnWbzXtxSfz/jKrpeqU1fW0lHVxd8
107
+ dFHLcQTvTu/R1JIVmC0RM9ZnsVTObJ8rTfazHYIt7/IsR+gj5E3MZmDJ7PzNv0kl
108
+ v01Iml0BAoGBAPpicmI3lTuyAwm8e7XXMbC4T7QinLN9XJeTc87EMM/KKFhiVjtr
109
+ gzcxUH0EqdfSd5bLU8fjW9H/xgQM82QNQzV2+AWY7wn2Lda1AE7xZYIjpBg+awV9
110
+ kKnRfDf3ThqKl5nmkmOQtYGNKKwn/u1ZTOSlQ1E2BqISdCNhupPhUZehAoGBANA2
111
+ WuBoU3IPKge/ELREz4GEdYSaHXZ8R3Au1vTXZQIRCUB/GJEoG2SmXxV1YFJMAm0B
112
+ 6/ZkWvhANf1BU4rcVMYuKJwS9XSFIlW0Npq8uMZKP4A8dnw+bz53XZJr5DsaPoWy
113
+ jm65UC+Tbqg0mZV0mJ5JMKiH5Ezfu03mJUuYmJgnAoGAVcFOB9GdrRpk6/rALCGO
114
+ BUa7FakdHmR7R/banSCYzzIf61WSzzsdb9PWC1uDiEWva9gr07RNCHmfqld9LPFV
115
+ 6YPbop8kj7bfMEBB4MfQymfGlf8azICbAW6cKtbqyzBYh/9ud+diIwLjwULZjxUc
116
+ vtrTWYc1cmD7ofqg2nE7bsECgYEAqCtOyTPaOiS/WNRcpI1zYHPhC0IDDAEjHhvm
117
+ 6IjUf4/M/jfpWsyfG3M5Fzbfnnjf+LV1pWO3Cg2qzaum02BUZGFB0ZWKhRtG+Rv+
118
+ goptX1L26Rdsx7sR1M1KWYolJAt1dj0ax5mLh3G4Dcm2Rr2Oy0HoOCbSIbkPKsL5
119
+ Wo6cqT8CgYAwMtF9qJYeEJtjgxuRVwlEUzcvxsNiuuUSFq9RpAXYL+F2U/P0SdQw
120
+ 06nf1JLvkcG2CyMbIB62BnQcuUyGAuhjtbpcsSn4MG00vfDNMPkaxOJ9W4S3mmnt
121
+ U2mXWYauJDvNdLEr42bVX3bTPTfR4zrIqe+oJJCH61Jcu/3ekpSkkA==
122
+ -----END RSA PRIVATE KEY-----
123
+
124
+
125
+ # List Symmetric Key files in the order of current / latest first
126
+ ciphers:
127
+ -
128
+ # Filename containing Symmetric Encryption Key encrypted using the
129
+ # RSA public key derived from the private key above
130
+ key_filename: config/keys/dummy_production.key
131
+ iv_filename: config/keys/dummy_production.iv
132
+ cipher_name: aes-256-cbc
133
+ # Base64 encode encrypted data without newlines
134
+ encoding: :base64strict
135
+ version: 1
data/db/ddl.sql CHANGED
@@ -1,10 +1,41 @@
1
1
  CREATE TABLE `kaui_users` (
2
2
  `id` int(11) NOT NULL AUTO_INCREMENT,
3
- `kb_tenant_id` varchar(255) DEFAULT NULL,
4
3
  `kb_username` varchar(255) NOT NULL,
5
4
  `kb_session_id` varchar(255) DEFAULT NULL,
6
5
  `created_at` datetime NOT NULL,
7
6
  `updated_at` datetime NOT NULL,
8
7
  PRIMARY KEY (`id`),
9
- UNIQUE KEY `index_kaui_users_on_kb_tenant_id_and_kb_username` (`kb_tenant_id`,`kb_username`)
8
+ UNIQUE KEY `index_kaui_users_on_kb_username` (`kb_username`)
10
9
  ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
10
+
11
+ CREATE TABLE `kaui_tenants` (
12
+ `id` int(11) NOT NULL AUTO_INCREMENT,
13
+ `name` varchar(255) DEFAULT NULL,
14
+ `kb_tenant_id` varchar(255) DEFAULT NULL,
15
+ `api_key` varchar(255) DEFAULT NULL,
16
+ `encrypted_api_secret` varchar(255) DEFAULT NULL,
17
+ `created_at` datetime NOT NULL,
18
+ `updated_at` datetime NOT NULL,
19
+ PRIMARY KEY (`id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+
22
+ CREATE TABLE `kaui_allowed_users` (
23
+ `id` int(11) NOT NULL AUTO_INCREMENT,
24
+ `kb_username` varchar(255) DEFAULT NULL,
25
+ `description` varchar(255) DEFAULT NULL,
26
+ `created_at` datetime NOT NULL,
27
+ `updated_at` datetime NOT NULL,
28
+ PRIMARY KEY (`id`),
29
+ KEY `kaui_allowed_users_idx` (`kb_username`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
31
+
32
+ CREATE TABLE `kaui_allowed_user_tenants` (
33
+ `id` int(11) NOT NULL AUTO_INCREMENT,
34
+ `kaui_allowed_user_id` int(11) DEFAULT NULL,
35
+ `kaui_tenant_id` int(11) DEFAULT NULL,
36
+ `created_at` datetime NOT NULL,
37
+ `updated_at` datetime NOT NULL,
38
+ PRIMARY KEY (`id`),
39
+ UNIQUE KEY `kaui_allowed_users_tenants_uniq` (`kaui_allowed_user_id`,`kaui_tenant_id`)
40
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
41
+
@@ -2,13 +2,11 @@ class DeviseCreateKauiUsers < ActiveRecord::Migration
2
2
  def change
3
3
  create_table(:kaui_users) do |t|
4
4
  # From Kill Bill
5
- t.string :kb_tenant_id, :null => true
6
5
  t.string :kb_username, :null => false
7
6
  t.string :kb_session_id, :null => true
8
-
9
7
  t.timestamps
10
8
  end
11
9
 
12
- add_index :kaui_users, [:kb_tenant_id, :kb_username], :unique => true
10
+ add_index :kaui_users, [:kb_username], :unique => true
13
11
  end
14
12
  end
@@ -0,0 +1,12 @@
1
+ class CreateKauiTenants < ActiveRecord::Migration
2
+ def change
3
+ create_table :kaui_tenants do |t|
4
+ t.string :name
5
+ t.string :kb_tenant_id
6
+ t.string :api_key
7
+ t.string :encrypted_api_secret
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end