maestrano-connector-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -0
  3. data/DEVELOPER.md +10 -0
  4. data/Gemfile +18 -0
  5. data/Gemfile.lock +222 -0
  6. data/LICENSE +21 -0
  7. data/README.md +138 -0
  8. data/Rakefile +37 -0
  9. data/VERSION +1 -0
  10. data/app/controllers/maestrano/account/group_users_controller.rb +20 -0
  11. data/app/controllers/maestrano/account/groups_controller.rb +22 -0
  12. data/app/controllers/maestrano/application_controller.rb +7 -0
  13. data/app/controllers/maestrano/auth/saml_controller.rb +31 -0
  14. data/app/controllers/maestrano/sessions_controller.rb +15 -0
  15. data/app/helpers/maestrano/connector/rails/session_helper.rb +17 -0
  16. data/app/jobs/maestrano/connector/rails/synchronization_job.rb +49 -0
  17. data/app/models/maestrano/connector/rails/complex_entity.rb +175 -0
  18. data/app/models/maestrano/connector/rails/concerns/entity.rb +231 -0
  19. data/app/models/maestrano/connector/rails/concerns/external.rb +13 -0
  20. data/app/models/maestrano/connector/rails/connector_logger.rb +9 -0
  21. data/app/models/maestrano/connector/rails/entity.rb +5 -0
  22. data/app/models/maestrano/connector/rails/external.rb +5 -0
  23. data/app/models/maestrano/connector/rails/id_map.rb +6 -0
  24. data/app/models/maestrano/connector/rails/organization.rb +60 -0
  25. data/app/models/maestrano/connector/rails/sub_entity_base.rb +32 -0
  26. data/app/models/maestrano/connector/rails/synchronization.rb +38 -0
  27. data/app/models/maestrano/connector/rails/user.rb +25 -0
  28. data/app/models/maestrano/connector/rails/user_organization_rel.rb +9 -0
  29. data/bin/rails +12 -0
  30. data/config/routes.rb +28 -0
  31. data/db/migrate/20151122162100_create_maestrano_connector_rails_users.rb +16 -0
  32. data/db/migrate/20151122162414_create_maestrano_connector_rails_organizations.rb +21 -0
  33. data/db/migrate/20151122162613_create_maestrano_connector_rails_user_organization_rels.rb +12 -0
  34. data/db/migrate/20151122163325_create_maestrano_connector_rails_synchronizations.rb +13 -0
  35. data/db/migrate/20151122163449_create_maestrano_connector_rails_id_maps.rb +18 -0
  36. data/lib/generators/connector/USAGE +2 -0
  37. data/lib/generators/connector/complex_entity_generator.rb +19 -0
  38. data/lib/generators/connector/install_generator.rb +70 -0
  39. data/lib/generators/connector/templates/admin_controller.rb +48 -0
  40. data/lib/generators/connector/templates/admin_index.html.erb +51 -0
  41. data/lib/generators/connector/templates/complex_entity_example/contact.rb +22 -0
  42. data/lib/generators/connector/templates/complex_entity_example/contact_and_lead.rb +56 -0
  43. data/lib/generators/connector/templates/complex_entity_example/contact_mapper.rb +17 -0
  44. data/lib/generators/connector/templates/complex_entity_example/lead.rb +22 -0
  45. data/lib/generators/connector/templates/complex_entity_example/lead_mapper.rb +15 -0
  46. data/lib/generators/connector/templates/complex_entity_example/person.rb +23 -0
  47. data/lib/generators/connector/templates/contact_and_lead.rb +55 -0
  48. data/lib/generators/connector/templates/entity.rb +48 -0
  49. data/lib/generators/connector/templates/example_entity.rb +26 -0
  50. data/lib/generators/connector/templates/external.rb +19 -0
  51. data/lib/generators/connector/templates/home_controller.rb +17 -0
  52. data/lib/generators/connector/templates/home_index.html.erb +42 -0
  53. data/lib/generators/connector/templates/oauth_controller.rb +45 -0
  54. data/lib/maestrano-connector-rails.rb +1 -0
  55. data/lib/maestrano/connector/rails.rb +13 -0
  56. data/maestrano-connector-rails.gemspec +197 -0
  57. data/maestrano.png +0 -0
  58. data/spec/dummy/README.md +1 -0
  59. data/spec/dummy/Rakefile +6 -0
  60. data/spec/dummy/app/assets/images/.keep +0 -0
  61. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  62. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  63. data/spec/dummy/app/controllers/admin_controller.rb +48 -0
  64. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  65. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  66. data/spec/dummy/app/controllers/home_controller.rb +17 -0
  67. data/spec/dummy/app/controllers/oauth_controller.rb +45 -0
  68. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  69. data/spec/dummy/app/mailers/.keep +0 -0
  70. data/spec/dummy/app/models/.keep +0 -0
  71. data/spec/dummy/app/models/concerns/.keep +0 -0
  72. data/spec/dummy/app/models/entities/example_entitiy.rb +26 -0
  73. data/spec/dummy/app/models/maestrano/connector/rails/entity.rb +10 -0
  74. data/spec/dummy/app/models/maestrano/connector/rails/external.rb +11 -0
  75. data/spec/dummy/app/views/admin/index.html.erb +51 -0
  76. data/spec/dummy/app/views/home/index.html.erb +36 -0
  77. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  78. data/spec/dummy/bin/bundle +3 -0
  79. data/spec/dummy/bin/rails +4 -0
  80. data/spec/dummy/bin/rake +4 -0
  81. data/spec/dummy/bin/setup +29 -0
  82. data/spec/dummy/config.ru +4 -0
  83. data/spec/dummy/config/application.rb +26 -0
  84. data/spec/dummy/config/boot.rb +5 -0
  85. data/spec/dummy/config/database.yml +25 -0
  86. data/spec/dummy/config/environment.rb +5 -0
  87. data/spec/dummy/config/environments/development.rb +41 -0
  88. data/spec/dummy/config/environments/production.rb +79 -0
  89. data/spec/dummy/config/environments/test.rb +42 -0
  90. data/spec/dummy/config/initializers/assets.rb +11 -0
  91. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  92. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  93. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  94. data/spec/dummy/config/initializers/inflections.rb +16 -0
  95. data/spec/dummy/config/initializers/maestrano.rb +135 -0
  96. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  97. data/spec/dummy/config/initializers/session_store.rb +3 -0
  98. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  99. data/spec/dummy/config/locales/en.yml +23 -0
  100. data/spec/dummy/config/routes.rb +9 -0
  101. data/spec/dummy/config/secrets.yml +22 -0
  102. data/spec/dummy/db/development.sqlite3 +0 -0
  103. data/spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb +17 -0
  104. data/spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb +22 -0
  105. data/spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb +13 -0
  106. data/spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb +14 -0
  107. data/spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb +19 -0
  108. data/spec/dummy/db/schema.rb +83 -0
  109. data/spec/dummy/lib/assets/.keep +0 -0
  110. data/spec/dummy/log/.keep +0 -0
  111. data/spec/dummy/public/404.html +67 -0
  112. data/spec/dummy/public/422.html +67 -0
  113. data/spec/dummy/public/500.html +66 -0
  114. data/spec/dummy/public/favicon.ico +0 -0
  115. data/spec/factories.rb +33 -0
  116. data/spec/jobs/syncrhonization_job_spec.rb +53 -0
  117. data/spec/models/complex_entity_spec.rb +353 -0
  118. data/spec/models/connector_logger_spec.rb +21 -0
  119. data/spec/models/entity_spec.rb +457 -0
  120. data/spec/models/external_spec.rb +15 -0
  121. data/spec/models/id_map_spec.rb +12 -0
  122. data/spec/models/organizaztion_spec.rb +105 -0
  123. data/spec/models/sub_entity_base_spec.rb +51 -0
  124. data/spec/models/synchronization_spec.rb +75 -0
  125. data/spec/models/user_organization_rel_spec.rb +14 -0
  126. data/spec/models/user_spec.rb +15 -0
  127. data/spec/spec_helper.rb +19 -0
  128. metadata +327 -0
@@ -0,0 +1,45 @@
1
+ class OauthController < ApplicationController
2
+
3
+ # TODO
4
+ # Routes for this controller are not provided by the gem and
5
+ # should be set according to your needs
6
+
7
+ def request_omniauth
8
+ org_uid = params[:org_uid]
9
+ organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
10
+
11
+ if organization && is_admin?(current_user, organization)
12
+ # TODO
13
+ # Perform oauth request here. The oauth process should be able to
14
+ # remember the organization, either by a param in the request or using
15
+ # a session
16
+ else
17
+ redirect_to root_url
18
+ end
19
+ end
20
+
21
+ def create_omniauth
22
+ org_uid = '' # TODO
23
+ organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
24
+
25
+ if organization && is_admin?(current_user, organization)
26
+ # TODO
27
+ # Update organization with oauth params
28
+ end
29
+
30
+ redirect_to root_url
31
+ end
32
+
33
+ def destroy_omniauth
34
+ organization = Maestrano::Connector::Rails::Organization.find(params[:organization_id])
35
+
36
+ if organization && is_admin?(current_user, organization)
37
+ organization.oauth_uid = nil
38
+ organization.oauth_token = nil
39
+ organization.refresh_token = nil
40
+ organization.save
41
+ end
42
+
43
+ redirect_to root_url
44
+ end
45
+ end
@@ -0,0 +1 @@
1
+ require 'maestrano/connector/rails'
@@ -0,0 +1,13 @@
1
+ require 'maestrano'
2
+ require 'maestrano-rails'
3
+ require 'hash_mapper'
4
+
5
+ module Maestrano
6
+ module Connector
7
+ module Rails
8
+ class Engine < ::Rails::Engine
9
+ # isolate_namespace Maestrano::Connector::Rails
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,197 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: maestrano-connector-rails 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "maestrano-connector-rails"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Pierre Berard"]
14
+ s.date = "2016-01-21"
15
+ s.description = "Maestrano is the next generation marketplace for SME applications. See https://maestrano.com for details."
16
+ s.email = "pierre.berard@maestrano.com"
17
+ s.executables = ["rails"]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE",
20
+ "README.md"
21
+ ]
22
+ s.files = [
23
+ ".rspec",
24
+ "DEVELOPER.md",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "app/controllers/maestrano/account/group_users_controller.rb",
32
+ "app/controllers/maestrano/account/groups_controller.rb",
33
+ "app/controllers/maestrano/application_controller.rb",
34
+ "app/controllers/maestrano/auth/saml_controller.rb",
35
+ "app/controllers/maestrano/sessions_controller.rb",
36
+ "app/helpers/maestrano/connector/rails/session_helper.rb",
37
+ "app/jobs/maestrano/connector/rails/synchronization_job.rb",
38
+ "app/models/maestrano/connector/rails/complex_entity.rb",
39
+ "app/models/maestrano/connector/rails/concerns/entity.rb",
40
+ "app/models/maestrano/connector/rails/concerns/external.rb",
41
+ "app/models/maestrano/connector/rails/connector_logger.rb",
42
+ "app/models/maestrano/connector/rails/entity.rb",
43
+ "app/models/maestrano/connector/rails/external.rb",
44
+ "app/models/maestrano/connector/rails/id_map.rb",
45
+ "app/models/maestrano/connector/rails/organization.rb",
46
+ "app/models/maestrano/connector/rails/sub_entity_base.rb",
47
+ "app/models/maestrano/connector/rails/synchronization.rb",
48
+ "app/models/maestrano/connector/rails/user.rb",
49
+ "app/models/maestrano/connector/rails/user_organization_rel.rb",
50
+ "bin/rails",
51
+ "config/routes.rb",
52
+ "db/migrate/20151122162100_create_maestrano_connector_rails_users.rb",
53
+ "db/migrate/20151122162414_create_maestrano_connector_rails_organizations.rb",
54
+ "db/migrate/20151122162613_create_maestrano_connector_rails_user_organization_rels.rb",
55
+ "db/migrate/20151122163325_create_maestrano_connector_rails_synchronizations.rb",
56
+ "db/migrate/20151122163449_create_maestrano_connector_rails_id_maps.rb",
57
+ "lib/generators/connector/USAGE",
58
+ "lib/generators/connector/complex_entity_generator.rb",
59
+ "lib/generators/connector/install_generator.rb",
60
+ "lib/generators/connector/templates/admin_controller.rb",
61
+ "lib/generators/connector/templates/admin_index.html.erb",
62
+ "lib/generators/connector/templates/complex_entity_example/contact.rb",
63
+ "lib/generators/connector/templates/complex_entity_example/contact_and_lead.rb",
64
+ "lib/generators/connector/templates/complex_entity_example/contact_mapper.rb",
65
+ "lib/generators/connector/templates/complex_entity_example/lead.rb",
66
+ "lib/generators/connector/templates/complex_entity_example/lead_mapper.rb",
67
+ "lib/generators/connector/templates/complex_entity_example/person.rb",
68
+ "lib/generators/connector/templates/contact_and_lead.rb",
69
+ "lib/generators/connector/templates/entity.rb",
70
+ "lib/generators/connector/templates/example_entity.rb",
71
+ "lib/generators/connector/templates/external.rb",
72
+ "lib/generators/connector/templates/home_controller.rb",
73
+ "lib/generators/connector/templates/home_index.html.erb",
74
+ "lib/generators/connector/templates/oauth_controller.rb",
75
+ "lib/maestrano-connector-rails.rb",
76
+ "lib/maestrano/connector/rails.rb",
77
+ "maestrano-connector-rails.gemspec",
78
+ "maestrano.png",
79
+ "spec/dummy/README.md",
80
+ "spec/dummy/Rakefile",
81
+ "spec/dummy/app/assets/images/.keep",
82
+ "spec/dummy/app/assets/javascripts/application.js",
83
+ "spec/dummy/app/assets/stylesheets/application.css",
84
+ "spec/dummy/app/controllers/admin_controller.rb",
85
+ "spec/dummy/app/controllers/application_controller.rb",
86
+ "spec/dummy/app/controllers/concerns/.keep",
87
+ "spec/dummy/app/controllers/home_controller.rb",
88
+ "spec/dummy/app/controllers/oauth_controller.rb",
89
+ "spec/dummy/app/helpers/application_helper.rb",
90
+ "spec/dummy/app/mailers/.keep",
91
+ "spec/dummy/app/models/.keep",
92
+ "spec/dummy/app/models/concerns/.keep",
93
+ "spec/dummy/app/models/entities/example_entitiy.rb",
94
+ "spec/dummy/app/models/maestrano/connector/rails/entity.rb",
95
+ "spec/dummy/app/models/maestrano/connector/rails/external.rb",
96
+ "spec/dummy/app/views/admin/index.html.erb",
97
+ "spec/dummy/app/views/home/index.html.erb",
98
+ "spec/dummy/app/views/layouts/application.html.erb",
99
+ "spec/dummy/bin/bundle",
100
+ "spec/dummy/bin/rails",
101
+ "spec/dummy/bin/rake",
102
+ "spec/dummy/bin/setup",
103
+ "spec/dummy/config.ru",
104
+ "spec/dummy/config/application.rb",
105
+ "spec/dummy/config/boot.rb",
106
+ "spec/dummy/config/database.yml",
107
+ "spec/dummy/config/environment.rb",
108
+ "spec/dummy/config/environments/development.rb",
109
+ "spec/dummy/config/environments/production.rb",
110
+ "spec/dummy/config/environments/test.rb",
111
+ "spec/dummy/config/initializers/assets.rb",
112
+ "spec/dummy/config/initializers/backtrace_silencers.rb",
113
+ "spec/dummy/config/initializers/cookies_serializer.rb",
114
+ "spec/dummy/config/initializers/filter_parameter_logging.rb",
115
+ "spec/dummy/config/initializers/inflections.rb",
116
+ "spec/dummy/config/initializers/maestrano.rb",
117
+ "spec/dummy/config/initializers/mime_types.rb",
118
+ "spec/dummy/config/initializers/session_store.rb",
119
+ "spec/dummy/config/initializers/wrap_parameters.rb",
120
+ "spec/dummy/config/locales/en.yml",
121
+ "spec/dummy/config/routes.rb",
122
+ "spec/dummy/config/secrets.yml",
123
+ "spec/dummy/db/development.sqlite3",
124
+ "spec/dummy/db/migrate/20151209134445_create_maestrano_connector_rails_users.maestrano_connector_rails.rb",
125
+ "spec/dummy/db/migrate/20151209134446_create_maestrano_connector_rails_organizations.maestrano_connector_rails.rb",
126
+ "spec/dummy/db/migrate/20151209134447_create_maestrano_connector_rails_user_organization_rels.maestrano_connector_rails.rb",
127
+ "spec/dummy/db/migrate/20151209134448_create_maestrano_connector_rails_synchronizations.maestrano_connector_rails.rb",
128
+ "spec/dummy/db/migrate/20151209134449_create_maestrano_connector_rails_id_maps.maestrano_connector_rails.rb",
129
+ "spec/dummy/db/schema.rb",
130
+ "spec/dummy/lib/assets/.keep",
131
+ "spec/dummy/log/.keep",
132
+ "spec/dummy/public/404.html",
133
+ "spec/dummy/public/422.html",
134
+ "spec/dummy/public/500.html",
135
+ "spec/dummy/public/favicon.ico",
136
+ "spec/factories.rb",
137
+ "spec/jobs/syncrhonization_job_spec.rb",
138
+ "spec/models/complex_entity_spec.rb",
139
+ "spec/models/connector_logger_spec.rb",
140
+ "spec/models/entity_spec.rb",
141
+ "spec/models/external_spec.rb",
142
+ "spec/models/id_map_spec.rb",
143
+ "spec/models/organizaztion_spec.rb",
144
+ "spec/models/sub_entity_base_spec.rb",
145
+ "spec/models/synchronization_spec.rb",
146
+ "spec/models/user_organization_rel_spec.rb",
147
+ "spec/models/user_spec.rb",
148
+ "spec/spec_helper.rb"
149
+ ]
150
+ s.homepage = "http://github.com/maestrano/maestrano-connector-rails"
151
+ s.licenses = ["MIT"]
152
+ s.rubygems_version = "2.4.6"
153
+ s.summary = "Rails framework to build connector with Maestrano"
154
+
155
+ if s.respond_to? :specification_version then
156
+ s.specification_version = 4
157
+
158
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
159
+ s.add_runtime_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
160
+ s.add_runtime_dependency(%q<hash_mapper>, ["~> 0.2.1"])
161
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
162
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
163
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
164
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
165
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
166
+ s.add_development_dependency(%q<rspec-rails>, [">= 0"])
167
+ s.add_development_dependency(%q<factory_girl_rails>, [">= 0"])
168
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
169
+ s.add_development_dependency(%q<shoulda-matchers>, [">= 0"])
170
+ else
171
+ s.add_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
172
+ s.add_dependency(%q<hash_mapper>, ["~> 0.2.1"])
173
+ s.add_dependency(%q<shoulda>, [">= 0"])
174
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
175
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
176
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
177
+ s.add_dependency(%q<simplecov>, [">= 0"])
178
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
179
+ s.add_dependency(%q<factory_girl_rails>, [">= 0"])
180
+ s.add_dependency(%q<sqlite3>, [">= 0"])
181
+ s.add_dependency(%q<shoulda-matchers>, [">= 0"])
182
+ end
183
+ else
184
+ s.add_dependency(%q<maestrano-rails>, ["~> 0.14.0"])
185
+ s.add_dependency(%q<hash_mapper>, ["~> 0.2.1"])
186
+ s.add_dependency(%q<shoulda>, [">= 0"])
187
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
188
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
189
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
190
+ s.add_dependency(%q<simplecov>, [">= 0"])
191
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
192
+ s.add_dependency(%q<factory_girl_rails>, [">= 0"])
193
+ s.add_dependency(%q<sqlite3>, [">= 0"])
194
+ s.add_dependency(%q<shoulda-matchers>, [">= 0"])
195
+ end
196
+ end
197
+
data/maestrano.png ADDED
Binary file
@@ -0,0 +1 @@
1
+ Dummy application for testing purpose
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,48 @@
1
+ # TODO
2
+ # This controller is given as an example of a possible admin implementation
3
+ # The admin functions should be restricted to admin users
4
+ # Admin funcitons :
5
+ # * Link account to external application
6
+ # * Disconnect account from external application
7
+ # * Launch a manual syncrhonization for all entities or a sub-part of them
8
+ # * Chose which entities are synchronized by the connector
9
+ # * Access a list of the organization's idmaps
10
+ class AdminController < ApplicationController
11
+
12
+ def index
13
+ if is_admin
14
+ @organization = current_organization
15
+ @idmaps = Maestrano::Connector::Rails::IdMap.where(organization_id: @organization.id).order(:connec_entity)
16
+ end
17
+ end
18
+
19
+ def update
20
+ organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:id])
21
+
22
+ if organization && is_admin?(current_user, organization)
23
+ organization.synchronized_entities.keys.each do |entity|
24
+ if !!params["#{entity}"]
25
+ organization.synchronized_entities[entity] = true
26
+ else
27
+ organization.synchronized_entities[entity] = false
28
+ end
29
+ end
30
+ organization.save
31
+ end
32
+
33
+ redirect_to admin_index_path
34
+ end
35
+
36
+ def synchronize
37
+ if is_admin
38
+ Delayed::Job.enqueue Maestrano::Connector::Rails::SynchronizationJob.new(current_organization, params['opts'] || {})
39
+ end
40
+
41
+ redirect_to root_path
42
+ end
43
+
44
+ private
45
+ def is_admin
46
+ current_user && current_organization && is_admin?(current_user, current_organization)
47
+ end
48
+ end
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ helper Maestrano::Connector::Rails::Engine.helpers
3
+ include Maestrano::Connector::Rails::SessionHelper
4
+
5
+ # Prevent CSRF attacks by raising an exception.
6
+ # For APIs, you may want to use :null_session instead.
7
+ protect_from_forgery with: :exception
8
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ # TODO
2
+ # This controller is given as an example of a possible home
3
+ # Admin funcitons :
4
+ # * Display generic information about the connector (mostly for not connected users)
5
+ # * Link the connector to a Maestrano organization
6
+ # * Acces the last synchronization and a synchronization history (with their status)
7
+ class HomeController < ApplicationController
8
+ def index
9
+ if current_user
10
+ @organization = current_organization
11
+
12
+ if @organization
13
+ @synchronizations = Maestrano::Connector::Rails::Synchronization.where(organization_id: @organization.id).order(updated_at: :desc).limit(40)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ class OauthController < ApplicationController
2
+
3
+ # TODO
4
+ # Routes for this controller are not provided by the gem and
5
+ # should be set according to your needs
6
+
7
+ def request_omniauth
8
+ org_uid = params[:org_uid]
9
+ organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
10
+
11
+ if organization && is_admin?(current_user, organization)
12
+ # TODO
13
+ # Perform oauth request here. The oauth process should be able to
14
+ # remember the organization, either by a param in the request or using
15
+ # a session
16
+ else
17
+ redirect_to root_url
18
+ end
19
+ end
20
+
21
+ def create_omniauth
22
+ org_uid = '' # TODO
23
+ organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
24
+
25
+ if organization && is_admin?(current_user, organization)
26
+ # TODO
27
+ # Update organization with oauth params
28
+ end
29
+
30
+ redirect_to root_url
31
+ end
32
+
33
+ def destroy_omniauth
34
+ organization = Maestrano::Connector::Rails::Organization.find(params[:organization_id])
35
+
36
+ if organization && is_admin?(current_user, organization)
37
+ organization.oauth_uid = nil
38
+ organization.oauth_token = nil
39
+ organization.refresh_token = nil
40
+ organization.save
41
+ end
42
+
43
+ redirect_to root_url
44
+ end
45
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes