openshift-origin-console 1.3.2
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.
- data/COPYRIGHT +1 -0
- data/Gemfile +21 -0
- data/LICENSE +203 -0
- data/README.md +123 -0
- data/Rakefile +44 -0
- data/app/assets/images/cartridge-edge.gif +0 -0
- data/app/assets/images/console/arrow-down.png +0 -0
- data/app/assets/images/console/console-sprite.png +0 -0
- data/app/assets/images/favicon-32.png +0 -0
- data/app/assets/images/loader-dark.gif +0 -0
- data/app/assets/images/loader.gif +0 -0
- data/app/assets/images/sprite-vert.png +0 -0
- data/app/assets/javascripts/console.js +10 -0
- data/app/assets/javascripts/console/form.js.coffee +51 -0
- data/app/assets/stylesheets/_alerts.scss +84 -0
- data/app/assets/stylesheets/_breadcrumbs.scss +31 -0
- data/app/assets/stylesheets/_buttons.scss +229 -0
- data/app/assets/stylesheets/_code.scss +86 -0
- data/app/assets/stylesheets/_custom.scss +207 -0
- data/app/assets/stylesheets/_footer.scss +54 -0
- data/app/assets/stylesheets/_forms.scss +710 -0
- data/app/assets/stylesheets/_grid.scss +28 -0
- data/app/assets/stylesheets/_input-prepend-append.scss +138 -0
- data/app/assets/stylesheets/_labels.scss +40 -0
- data/app/assets/stylesheets/_mixins.scss +76 -0
- data/app/assets/stylesheets/_override-variables.scss +1 -0
- data/app/assets/stylesheets/_responsive.scss +438 -0
- data/app/assets/stylesheets/_ribbon.scss +57 -0
- data/app/assets/stylesheets/_type.scss +306 -0
- data/app/assets/stylesheets/_utilities.scss +10 -0
- data/app/assets/stylesheets/_variables.scss +131 -0
- data/app/assets/stylesheets/common.css.scss +82 -0
- data/app/assets/stylesheets/console/_application.scss +194 -0
- data/app/assets/stylesheets/console/_base.scss +26 -0
- data/app/assets/stylesheets/console/_breadcrumbs.scss +32 -0
- data/app/assets/stylesheets/console/_buttons.scss +214 -0
- data/app/assets/stylesheets/console/_core.scss +1002 -0
- data/app/assets/stylesheets/console/_dropdowns.scss +63 -0
- data/app/assets/stylesheets/console/_help.scss +54 -0
- data/app/assets/stylesheets/console/_mixins.scss +11 -0
- data/app/assets/stylesheets/console/_navbar.scss +415 -0
- data/app/assets/stylesheets/console/_ribbon.scss +82 -0
- data/app/assets/stylesheets/console/_tile.scss +122 -0
- data/app/assets/stylesheets/origin.css.scss +37 -0
- data/app/controllers/account/dashboard.rb +13 -0
- data/app/controllers/account_controller.rb +3 -0
- data/app/controllers/application_types_controller.rb +80 -0
- data/app/controllers/applications_controller.rb +183 -0
- data/app/controllers/building_controller.rb +81 -0
- data/app/controllers/capability_aware.rb +18 -0
- data/app/controllers/cartridge_types_controller.rb +53 -0
- data/app/controllers/cartridges_controller.rb +43 -0
- data/app/controllers/console/auth/basic.rb +65 -0
- data/app/controllers/console/auth/none.rb +5 -0
- data/app/controllers/console/auth/remote_user.rb +69 -0
- data/app/controllers/console/rescue.rb +48 -0
- data/app/controllers/console_controller.rb +19 -0
- data/app/controllers/console_index_controller.rb +14 -0
- data/app/controllers/domain_aware.rb +26 -0
- data/app/controllers/domain_session_sweeper.rb +29 -0
- data/app/controllers/domains_controller.rb +30 -0
- data/app/controllers/keys_controller.rb +43 -0
- data/app/controllers/scaling_controller.rb +46 -0
- data/app/controllers/sshkey_aware.rb +23 -0
- data/app/controllers/sshkey_session_sweeper.rb +29 -0
- data/app/controllers/user_session_sweeper.rb +29 -0
- data/app/helpers/console/community_helper.rb +78 -0
- data/app/helpers/console/console_helper.rb +26 -0
- data/app/helpers/console/help_helper.rb +270 -0
- data/app/helpers/console/html5_boilerplate_helper.rb +63 -0
- data/app/helpers/console/layout_helper.rb +277 -0
- data/app/helpers/console/model_helper.rb +106 -0
- data/app/helpers/console/secured_helper.rb +5 -0
- data/app/models/alias.rb +10 -0
- data/app/models/application.rb +148 -0
- data/app/models/application_associations.rb +36 -0
- data/app/models/application_template.rb +90 -0
- data/app/models/application_type.rb +258 -0
- data/app/models/async_aware.rb +60 -0
- data/app/models/capabilities.rb +62 -0
- data/app/models/cartridge.rb +122 -0
- data/app/models/cartridge_type.rb +140 -0
- data/app/models/domain.rb +44 -0
- data/app/models/domain_associations.rb +33 -0
- data/app/models/embedded.rb +11 -0
- data/app/models/gear.rb +13 -0
- data/app/models/gear_group.rb +104 -0
- data/app/models/key.rb +87 -0
- data/app/models/quickstart.rb +135 -0
- data/app/models/rest_api.rb +130 -0
- data/app/models/rest_api/base.rb +781 -0
- data/app/models/rest_api/cacheable.rb +91 -0
- data/app/models/rest_api/environment.rb +13 -0
- data/app/models/rest_api/info.rb +34 -0
- data/app/models/rest_api/log_subscriber.rb +29 -0
- data/app/models/rest_api/railties/controller_runtime.rb +37 -0
- data/app/models/user.rb +27 -0
- data/app/models/user_associations.rb +6 -0
- data/app/views/account/_domain.html.haml +14 -0
- data/app/views/account/_keys.html.haml +20 -0
- data/app/views/account/_user.html.haml +5 -0
- data/app/views/account/show.html.haml +15 -0
- data/app/views/application_templates/_application_template.html.haml +5 -0
- data/app/views/application_types/_application_type.html.haml +19 -0
- data/app/views/application_types/_custom.html.haml +19 -0
- data/app/views/application_types/_persisted.html.haml +26 -0
- data/app/views/application_types/_tile.html.haml +9 -0
- data/app/views/application_types/index.html.haml +87 -0
- data/app/views/application_types/search.html.haml +67 -0
- data/app/views/application_types/show.html.haml +219 -0
- data/app/views/applications/_application.html.haml +34 -0
- data/app/views/applications/_applications_filter.html.haml +8 -0
- data/app/views/applications/_footer.html.haml +0 -0
- data/app/views/applications/_name.html.haml +28 -0
- data/app/views/applications/delete.html.haml +19 -0
- data/app/views/applications/get_started.html.haml +145 -0
- data/app/views/applications/index.html.haml +55 -0
- data/app/views/applications/show.html.haml +193 -0
- data/app/views/building/delete.html.haml +22 -0
- data/app/views/building/new.html.haml +57 -0
- data/app/views/building/show.html.haml +12 -0
- data/app/views/cartridge_types/_cartridge_type.html.haml +61 -0
- data/app/views/cartridge_types/index.html.haml +37 -0
- data/app/views/cartridge_types/show.html.haml +21 -0
- data/app/views/cartridges/next_steps.html.haml +58 -0
- data/app/views/cartridges/show.html.haml +1 -0
- data/app/views/console/error.html.haml +58 -0
- data/app/views/console/help.html.haml +90 -0
- data/app/views/console/not_found.html.haml +69 -0
- data/app/views/console/unauthorized.html.haml +7 -0
- data/app/views/domains/_domain.html.haml +14 -0
- data/app/views/domains/_form.html.haml +13 -0
- data/app/views/domains/edit.html.haml +5 -0
- data/app/views/domains/new.html.haml +6 -0
- data/app/views/keys/_form.html.haml +14 -0
- data/app/views/keys/_simple_form.html.haml +14 -0
- data/app/views/keys/new.html.haml +2 -0
- data/app/views/layouts/_footer.html.haml +38 -0
- data/app/views/layouts/_head.html.haml +35 -0
- data/app/views/layouts/console.html.haml +60 -0
- data/app/views/layouts/console/_header.html.haml +44 -0
- data/app/views/layouts/console/_identity.html.haml +7 -0
- data/app/views/layouts/console/_javascripts.html.haml +5 -0
- data/app/views/layouts/console/_stylesheets.html.haml +6 -0
- data/app/views/scaling/delete.html.haml +17 -0
- data/app/views/scaling/new.html.haml +24 -0
- data/app/views/scaling/show.html.haml +81 -0
- data/app/views/shared/_tracking.html.haml +0 -0
- data/conf/console.conf.example +108 -0
- data/conf/openshift_console.conf +10 -0
- data/config/cartridge_types.yml +54 -0
- data/config/initializers/barista_config.rb +86 -0
- data/config/initializers/cartridge_types.rb +5 -0
- data/config/initializers/console_security.rb +1 -0
- data/config/initializers/date_helper.rb +5 -0
- data/config/initializers/extended_logger.rb +51 -0
- data/config/initializers/formtastic.rb +100 -0
- data/config/initializers/inflections.rb +38 -0
- data/config/initializers/rdiscount.rb +8 -0
- data/config/initializers/rest_api.rb +22 -0
- data/config/initializers/sass.rb +30 -0
- data/config/initializers/session_trace.rb +32 -0
- data/config/initializers/x_frame_options.rb +53 -0
- data/config/locales/en.yml +12 -0
- data/lib/active_resource/associations.rb +107 -0
- data/lib/active_resource/associations/builder/association.rb +35 -0
- data/lib/active_resource/associations/builder/belongs_to.rb +5 -0
- data/lib/active_resource/associations/builder/has_many.rb +5 -0
- data/lib/active_resource/associations/builder/has_one.rb +5 -0
- data/lib/active_resource/persistent_connection.rb +341 -0
- data/lib/active_resource/persistent_http_mock.rb +68 -0
- data/lib/active_resource/reflection.rb +78 -0
- data/lib/console.rb +8 -0
- data/lib/console/config_file.rb +13 -0
- data/lib/console/configuration.rb +163 -0
- data/lib/console/engine.rb +28 -0
- data/lib/console/formtastic/bootstrap_form_builder.rb +369 -0
- data/lib/console/rails/app_redirector.rb +40 -0
- data/lib/console/rails/filter_hash.rb +15 -0
- data/lib/console/rails/routes.rb +51 -0
- data/lib/console/version.rb +5 -0
- data/lib/tasks/assets.rake +79 -0
- data/lib/tasks/stats.rake +18 -0
- data/lib/tasks/test_suites.rake +73 -0
- data/test/coverage_helper.rb +27 -0
- data/test/fixtures/cartridges.json +1 -0
- data/test/fixtures/quickstarts.csv +3 -0
- data/test/functional/account_controller_test.rb +14 -0
- data/test/functional/application_types_controller_test.rb +251 -0
- data/test/functional/applications_controller_sanity_test.rb +26 -0
- data/test/functional/applications_controller_test.rb +365 -0
- data/test/functional/building_controller_test.rb +203 -0
- data/test/functional/cartridge_types_controller_isolation_test.rb +68 -0
- data/test/functional/cartridge_types_controller_test.rb +48 -0
- data/test/functional/cartridges_controller_test.rb +83 -0
- data/test/functional/console_auth_basic_controller_test.rb +82 -0
- data/test/functional/console_auth_remote_user_controller_test.rb +90 -0
- data/test/functional/console_index_controller_test.rb +22 -0
- data/test/functional/domains_controller_test.rb +194 -0
- data/test/functional/keys_controller_test.rb +163 -0
- data/test/functional/quickstarts.json +18 -0
- data/test/functional/scaling_controller_test.rb +153 -0
- data/test/integration/assets_test.rb +34 -0
- data/test/integration/help_link_test.rb +43 -0
- data/test/integration/quickstarts_test.rb +24 -0
- data/test/integration/rescue_from_test.rb +25 -0
- data/test/integration/rest_api/application_test.rb +115 -0
- data/test/integration/rest_api/cartridge_test.rb +44 -0
- data/test/integration/rest_api/cartridge_type_test.rb +143 -0
- data/test/integration/rest_api/domain_test.rb +91 -0
- data/test/integration/rest_api/info_test.rb +9 -0
- data/test/integration/rest_api/key_test.rb +85 -0
- data/test/integration/static_pages_test.rb +44 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +5 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +48 -0
- data/test/rails_app/config/boot.rb +10 -0
- data/test/rails_app/config/database.yml +25 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +38 -0
- data/test/rails_app/config/environments/production.rb +70 -0
- data/test/rails_app/config/environments/test.rb +43 -0
- data/test/rails_app/config/initializers/auth.rb +0 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/en.yml +5 -0
- data/test/rails_app/config/routes.rb +4 -0
- data/test/rails_app/script/rails +6 -0
- data/test/support/auth.rb +111 -0
- data/test/support/base.rb +142 -0
- data/test/support/errors.rb +28 -0
- data/test/support/rest_api.rb +189 -0
- data/test/test_helper.rb +14 -0
- data/test/unit/active_model_compliance_test.rb +23 -0
- data/test/unit/async_aware_test.rb +55 -0
- data/test/unit/configuration_test.rb +158 -0
- data/test/unit/filter_hash_test.rb +64 -0
- data/test/unit/helpers/model_helper_test.rb +61 -0
- data/test/unit/overrides_test.rb +9 -0
- data/test/unit/rest_api_test.rb +1590 -0
- data/vendor/assets/javascripts/MIT-LICENSE.txt +20 -0
- data/vendor/assets/javascripts/bootstrap-collapse.js +157 -0
- data/vendor/assets/javascripts/bootstrap-dropdown.js +100 -0
- data/vendor/assets/javascripts/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/bootstrap-transition.js +61 -0
- data/vendor/assets/javascripts/jquery.spin.js +47 -0
- data/vendor/assets/javascripts/jquery.ui.widget.js +16 -0
- data/vendor/assets/javascripts/jquery_cookie.js +41 -0
- data/vendor/assets/javascripts/jquery_validate_min.js +51 -0
- data/vendor/assets/javascripts/modernizr.min.js +2 -0
- data/vendor/assets/javascripts/plugins.js +16 -0
- data/vendor/assets/stylesheets/bootstrap/_accordion.scss +28 -0
- data/vendor/assets/stylesheets/bootstrap/_alerts.scss +70 -0
- data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +22 -0
- data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +147 -0
- data/vendor/assets/stylesheets/bootstrap/_buttons.scss +183 -0
- data/vendor/assets/stylesheets/bootstrap/_carousel.scss +121 -0
- data/vendor/assets/stylesheets/bootstrap/_close.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_code.scss +57 -0
- data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +130 -0
- data/vendor/assets/stylesheets/bootstrap/_forms.scss +522 -0
- data/vendor/assets/stylesheets/bootstrap/_grid.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/_hero-unit.scss +20 -0
- data/vendor/assets/stylesheets/bootstrap/_labels.scss +32 -0
- data/vendor/assets/stylesheets/bootstrap/_layouts.scss +17 -0
- data/vendor/assets/stylesheets/bootstrap/_mixins.scss +602 -0
- data/vendor/assets/stylesheets/bootstrap/_modals.scss +84 -0
- data/vendor/assets/stylesheets/bootstrap/_navbar.scss +299 -0
- data/vendor/assets/stylesheets/bootstrap/_navs.scss +353 -0
- data/vendor/assets/stylesheets/bootstrap/_pager.scss +30 -0
- data/vendor/assets/stylesheets/bootstrap/_pagination.scss +55 -0
- data/vendor/assets/stylesheets/bootstrap/_popovers.scss +49 -0
- data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
- data/vendor/assets/stylesheets/bootstrap/_reset.scss +126 -0
- data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +33 -0
- data/vendor/assets/stylesheets/bootstrap/_sprites.scss +158 -0
- data/vendor/assets/stylesheets/bootstrap/_tables.scss +150 -0
- data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_type.scss +218 -0
- data/vendor/assets/stylesheets/bootstrap/_utilities.scss +23 -0
- data/vendor/assets/stylesheets/bootstrap/_variables.scss +107 -0
- data/vendor/assets/stylesheets/bootstrap/_wells.scss +17 -0
- data/vendor/assets/stylesheets/bootstrap/bootstrap.scss +66 -0
- data/vendor/assets/stylesheets/bootstrap/responsive.scss +334 -0
- metadata +506 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
class BuildingController < ConsoleController
|
|
2
|
+
|
|
3
|
+
def show
|
|
4
|
+
user_default_domain
|
|
5
|
+
@application = @domain.find_application params[:application_id]
|
|
6
|
+
redirect_to new_application_building_path(@application) unless @application.builds?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def new
|
|
10
|
+
user_default_domain
|
|
11
|
+
@application = @domain.find_application params[:application_id]
|
|
12
|
+
@jenkins_server = if @application.building_app
|
|
13
|
+
@domain.find_application(@application.building_app) if @application.building_app
|
|
14
|
+
else
|
|
15
|
+
Application.new({:name => 'jenkins'}, false)
|
|
16
|
+
end
|
|
17
|
+
@cartridge_type = CartridgeType.cached.all.find{ |c| c.tags.include? :ci_builder }
|
|
18
|
+
@cartridge = Cartridge.new :name => @cartridge_type.name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create
|
|
22
|
+
@domain = Domain.find :one, :as => current_user
|
|
23
|
+
@application = @domain.find_application(params[:application_id])
|
|
24
|
+
@jenkins_server = @domain.find_application(@application.building_app) if @application.building_app
|
|
25
|
+
@cartridge_type = CartridgeType.cached.all.find{ |c| c.tags.include? :ci_builder }
|
|
26
|
+
@cartridge = Cartridge.new :name => @cartridge_type.name
|
|
27
|
+
|
|
28
|
+
unless @jenkins_server
|
|
29
|
+
framework = CartridgeType.cached.all.find{ |c| c.tags.include? :ci }
|
|
30
|
+
@jenkins_server = Application.new(
|
|
31
|
+
:name => params[:application][:name],
|
|
32
|
+
:cartridge => framework.name,
|
|
33
|
+
:domain => @domain,
|
|
34
|
+
:as => current_user)
|
|
35
|
+
|
|
36
|
+
if @jenkins_server.save
|
|
37
|
+
message = @jenkins_server.remote_results
|
|
38
|
+
else
|
|
39
|
+
render :new and return
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
@cartridge.application = @application
|
|
44
|
+
|
|
45
|
+
success, attempts = @cartridge.save, 1
|
|
46
|
+
while (!success && @cartridge.has_exit_code?(157, :on => :cartridge) && attempts < 2)
|
|
47
|
+
logger.debug " Jenkins server could not be contacted, sleep and then retry\n #{@cartridge.errors.inspect}"
|
|
48
|
+
sleep(10)
|
|
49
|
+
success = @cartridge.save
|
|
50
|
+
attempts += 1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
if success
|
|
54
|
+
redirect_to application_building_path(@application), :flash => {:info_pre => @cartridge.remote_results.concat(message || []).concat(['Your application is now building with Jenkins.'])}
|
|
55
|
+
else
|
|
56
|
+
if @cartridge.has_exit_code?(157, :on => :cartridge)
|
|
57
|
+
message = 'The Jenkins server is not yet registered with DNS. Please wait a few minutes before trying again.'
|
|
58
|
+
else
|
|
59
|
+
@cartridge.errors.full_messages.each{ |m| @jenkins_server.errors.add(:base, m) }
|
|
60
|
+
end
|
|
61
|
+
flash.now[:info_pre] = message
|
|
62
|
+
render :new
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def delete
|
|
67
|
+
user_default_domain
|
|
68
|
+
@application = @domain.find_application params[:application_id]
|
|
69
|
+
redirect_to new_application_building_path(@application) unless @application.builds?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def destroy
|
|
73
|
+
@domain = Domain.find :one, :as => current_user
|
|
74
|
+
@application = @domain.find_application params[:application_id]
|
|
75
|
+
if @application.destroy_build_cartridge
|
|
76
|
+
redirect_to application_path(@application), :flash => {:success => "#{@application.name} is no longer building through Jenkins."}
|
|
77
|
+
else
|
|
78
|
+
render :delete
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module CapabilityAware
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
around_filter UserSessionSweeper
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Call this with :refresh => true to force a
|
|
9
|
+
# refresh of the values stored in session
|
|
10
|
+
def user_capabilities(args = {})
|
|
11
|
+
@user_capabilities = nil if args[:refresh]
|
|
12
|
+
@user_capabilities ||=
|
|
13
|
+
(Capabilities::Cacheable.from(session[:user_capabilities]) rescue nil) ||
|
|
14
|
+
User.find(:one, :as => current_user).to_capabilities.tap{ |c| session[:user_capabilities] = c.to_a }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
RestApi::Base.observers << UserSessionSweeper
|
|
18
|
+
UserSessionSweeper.instance
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class CartridgeTypesController < ConsoleController
|
|
2
|
+
|
|
3
|
+
def index
|
|
4
|
+
user_default_domain
|
|
5
|
+
|
|
6
|
+
@application = @domain.find_application params[:application_id]
|
|
7
|
+
installed_carts = @application.cartridges
|
|
8
|
+
|
|
9
|
+
types = CartridgeType.cached.embedded
|
|
10
|
+
|
|
11
|
+
@blocked = []
|
|
12
|
+
|
|
13
|
+
@installed, types = types.partition{ |t| installed_carts.any?{ |c| c.name == t.name } }
|
|
14
|
+
@blacklist, types = types.partition{ |t| t.tags.include?(:blacklist) }
|
|
15
|
+
|
|
16
|
+
@conflicts, types = types.partition{ |t| conflicts? t }
|
|
17
|
+
@requires, types = types.partition{ |t| requires? t }
|
|
18
|
+
|
|
19
|
+
@installed.sort!; @conflicts.sort!; @requires.sort!
|
|
20
|
+
@carts = types.sort!
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def show
|
|
24
|
+
user_default_domain
|
|
25
|
+
@application = @domain.find_application params[:application_id]
|
|
26
|
+
|
|
27
|
+
@cartridge_type = CartridgeType.cached.find params[:id]
|
|
28
|
+
@cartridge = Cartridge.new :as => current_user
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def conflicts?(cart_type)
|
|
32
|
+
t = cart_type
|
|
33
|
+
|
|
34
|
+
return false if @installed.nil? || t.conflicts.empty?
|
|
35
|
+
|
|
36
|
+
# if this cart can conflict and a conflicting cart is installed
|
|
37
|
+
# add this cart to the conflicted list
|
|
38
|
+
@installed.each { |c| return true if t.conflicts.include? c.name }
|
|
39
|
+
return false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def requires?(cart_type)
|
|
43
|
+
t = cart_type
|
|
44
|
+
|
|
45
|
+
return true if @installed.nil? && !t.requires.empty?
|
|
46
|
+
return false if t.requires.empty?
|
|
47
|
+
|
|
48
|
+
# if this cart has requirements and the required cart is not
|
|
49
|
+
# installed add this cart to the requires list
|
|
50
|
+
@installed.each { |c| return false if t.requires.include? c.name }
|
|
51
|
+
return true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class CartridgesController < ConsoleController
|
|
2
|
+
|
|
3
|
+
def index
|
|
4
|
+
# on index get, redirect back to application details page
|
|
5
|
+
redirect_to application_path(params['application_id'])
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def show
|
|
9
|
+
user_default_domain
|
|
10
|
+
@application = @domain.find_application params[:application_id]
|
|
11
|
+
@application_type = ApplicationType.find @application.framework
|
|
12
|
+
Rails.logger.debug @application.cartridges
|
|
13
|
+
@cartridge = @application.find_cartridge params[:id]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create
|
|
17
|
+
cart_params = params[:cartridge]
|
|
18
|
+
@domain = Domain.find :one, :as => current_user
|
|
19
|
+
@application = @domain.find_application params[:application_id]
|
|
20
|
+
# TODO: check for app errors and redirect to app list if error
|
|
21
|
+
|
|
22
|
+
@cartridge = Cartridge.new cart_params
|
|
23
|
+
|
|
24
|
+
@cartridge.application = @application
|
|
25
|
+
@cartridge.as = current_user
|
|
26
|
+
|
|
27
|
+
@cartridge_type = CartridgeType.find cart_params[:name], :as => current_user
|
|
28
|
+
|
|
29
|
+
if @cartridge.save
|
|
30
|
+
@wizard = true
|
|
31
|
+
|
|
32
|
+
message = @cartridge.remote_results
|
|
33
|
+
flash.now[:info_pre] = message
|
|
34
|
+
|
|
35
|
+
render :next_steps
|
|
36
|
+
else
|
|
37
|
+
Rails.logger.debug @cartridge.errors.inspect
|
|
38
|
+
@application_id = @application.id
|
|
39
|
+
render 'cartridge_types/show'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The simplest possible security strategy - this controller mixin
|
|
3
|
+
# will challenge the user with BASIC authentication, pass that
|
|
4
|
+
# information to the broker, and then cache the ticket and the user
|
|
5
|
+
# identifier in the session until the ticket expires.
|
|
6
|
+
#
|
|
7
|
+
module Console::Auth::Basic
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
class BasicUser < RestApi::Authorization
|
|
11
|
+
extend ActiveModel::Naming
|
|
12
|
+
include ActiveModel::Conversion
|
|
13
|
+
|
|
14
|
+
def initialize(opts={})
|
|
15
|
+
opts.each_pair { |key,value| instance_variable_set("@#{key}", value) }
|
|
16
|
+
end
|
|
17
|
+
def email_address
|
|
18
|
+
nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def persisted?
|
|
22
|
+
false
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
included do
|
|
27
|
+
helper_method :current_user, :user_signed_in?, :previously_signed_in?
|
|
28
|
+
|
|
29
|
+
rescue_from ActiveResource::UnauthorizedAccess, :with => :console_access_denied
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# return the current authenticated user or nil
|
|
33
|
+
def current_user
|
|
34
|
+
@authenticated_user
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# This method should test authentication and handle if the user
|
|
38
|
+
# is unauthenticated
|
|
39
|
+
def authenticate_user!
|
|
40
|
+
authenticate_or_request_with_http_basic(auth_realm) do |login,password|
|
|
41
|
+
if login.present?
|
|
42
|
+
@authenticated_user = BasicUser.new :login => login, :password => password
|
|
43
|
+
else
|
|
44
|
+
raise Console::AccessDenied
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def user_signed_in?
|
|
50
|
+
not current_user.nil?
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def previously_signed_in?
|
|
54
|
+
cookies[:prev_login] ? true : false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
protected
|
|
58
|
+
def auth_realm
|
|
59
|
+
"Authenticate to #{RestApi.site.host}"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def console_access_denied
|
|
63
|
+
request_http_basic_authentication(auth_realm)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The simplest possible security strategy - this controller mixin
|
|
3
|
+
# will look for user info as a header on the request, and pass that
|
|
4
|
+
# info down to the broker. The broker should be configured to
|
|
5
|
+
# authenticate with those headers.
|
|
6
|
+
#
|
|
7
|
+
module Console::Auth::RemoteUser
|
|
8
|
+
extend ActiveSupport::Concern
|
|
9
|
+
|
|
10
|
+
class RemoteUser < RestApi::Authorization
|
|
11
|
+
extend ActiveModel::Naming
|
|
12
|
+
include ActiveModel::Conversion
|
|
13
|
+
|
|
14
|
+
def initialize(username, headers)
|
|
15
|
+
@username = username
|
|
16
|
+
@headers = headers.freeze
|
|
17
|
+
end
|
|
18
|
+
def login
|
|
19
|
+
@username
|
|
20
|
+
end
|
|
21
|
+
def email_address
|
|
22
|
+
nil
|
|
23
|
+
end
|
|
24
|
+
def to_headers
|
|
25
|
+
@headers
|
|
26
|
+
end
|
|
27
|
+
def persisted?
|
|
28
|
+
false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
included do
|
|
33
|
+
helper_method :current_user, :user_signed_in?, :previously_signed_in?
|
|
34
|
+
|
|
35
|
+
rescue_from ActiveResource::UnauthorizedAccess, :with => :console_access_denied
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# return the current authenticated user or nil
|
|
39
|
+
def current_user
|
|
40
|
+
@authenticated_user
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# This method should test authentication and handle if the user
|
|
44
|
+
# is unauthenticated
|
|
45
|
+
def authenticate_user!
|
|
46
|
+
@authenticated_user ||= begin
|
|
47
|
+
name = request.env[Console.config.remote_user_header]
|
|
48
|
+
raise Console::AccessDenied unless name
|
|
49
|
+
display_name = request.env[Console.config.remote_user_name_header] unless Console.config.remote_user_name_header.nil?
|
|
50
|
+
name = display_name || name
|
|
51
|
+
logger.debug " Identified user #{name} from headers"
|
|
52
|
+
RemoteUser.new(
|
|
53
|
+
name,
|
|
54
|
+
Console.config.remote_user_copy_headers.inject({}) do |h, name|
|
|
55
|
+
value = request.headers[name]
|
|
56
|
+
h[name] = value if value.present?
|
|
57
|
+
h
|
|
58
|
+
end)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def user_signed_in?
|
|
63
|
+
not current_user.nil?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def previously_signed_in?
|
|
67
|
+
cookies[:prev_login] ? true : false
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Console
|
|
2
|
+
module Rescue
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
rescue_from ActiveResource::ConnectionError, :with => :generic_error
|
|
7
|
+
rescue_from ActiveResource::ResourceNotFound, :with => :page_not_found
|
|
8
|
+
rescue_from RestApi::ResourceNotFound, :with => :resource_not_found
|
|
9
|
+
rescue_from Console::AccessDenied, :with => :console_access_denied
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
def resource_not_found(e)
|
|
14
|
+
if respond_to? :domain_is_missing
|
|
15
|
+
domain_is_missing if e.respond_to?(:domain_missing?) && e.domain_missing?
|
|
16
|
+
end
|
|
17
|
+
alternatives = if Application == e.model
|
|
18
|
+
@domain.applications.map do |app|
|
|
19
|
+
["Application #{app.name}", application_path(app)]
|
|
20
|
+
end.tap do |links|
|
|
21
|
+
links << ['Create a new application', new_application_path] if links.empty?
|
|
22
|
+
end if @domain rescue nil
|
|
23
|
+
elsif ApplicationType == e.model
|
|
24
|
+
[['See other application types', application_types_path]]
|
|
25
|
+
end
|
|
26
|
+
page_not_found(e, e.message, alternatives)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def page_not_found(e=nil, message=nil, alternatives=nil)
|
|
30
|
+
@reference_id = request.uuid
|
|
31
|
+
logger.warn "Page not found - Reference ##{@reference_id}"
|
|
32
|
+
@message, @alternatives = message, alternatives
|
|
33
|
+
render 'console/not_found'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def generic_error(e=nil, message=nil, alternatives=nil)
|
|
37
|
+
@reference_id = request.uuid
|
|
38
|
+
logger.error "Unhandled exception reference ##{@reference_id}: #{e.message}\n#{e.backtrace.join("\n ")}"
|
|
39
|
+
@message, @alternatives = message, alternatives
|
|
40
|
+
render 'console/error'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def console_access_denied(e)
|
|
44
|
+
logger.debug "Access denied: #{e}"
|
|
45
|
+
redirect_to unauthorized_path
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class ConsoleController < Console.config.parent_controller.constantize
|
|
2
|
+
include Console.config.security_controller.constantize
|
|
3
|
+
include CapabilityAware
|
|
4
|
+
include DomainAware
|
|
5
|
+
include SshkeyAware
|
|
6
|
+
|
|
7
|
+
layout 'console'
|
|
8
|
+
|
|
9
|
+
before_filter :authenticate_user!
|
|
10
|
+
|
|
11
|
+
def active_tab
|
|
12
|
+
nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
protected
|
|
16
|
+
def to_boolean(param)
|
|
17
|
+
['1','on','true'].include?(param.to_s.downcase) if param
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ConsoleIndexController < ConsoleController
|
|
2
|
+
skip_before_filter :authenticate_user!, :only => :unauthorized
|
|
3
|
+
|
|
4
|
+
def index
|
|
5
|
+
redirect_to applications_path
|
|
6
|
+
end
|
|
7
|
+
def unauthorized
|
|
8
|
+
render 'console/unauthorized'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def help
|
|
12
|
+
render 'console/help'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module DomainAware
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
around_filter DomainSessionSweeper
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def user_default_domain
|
|
9
|
+
@domain ||= begin
|
|
10
|
+
if name = session[:domain]
|
|
11
|
+
logger.debug " Using cached domain #{name}"
|
|
12
|
+
Domain.new({:id => name, :as => current_user}, true)
|
|
13
|
+
else
|
|
14
|
+
Domain.find(:one, :as => current_user).tap do |domain|
|
|
15
|
+
session[:domain] = domain.id
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def domain_is_missing
|
|
22
|
+
session.delete :domain
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
RestApi::Base.observers << DomainSessionSweeper
|
|
26
|
+
DomainSessionSweeper.instance
|