mno-enterprise-api 2.0.0
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 +7 -0
- data/LICENSE +1 -0
- data/Rakefile +12 -0
- data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
- data/app/assets/javascripts/mno_enterprise/application.js +13 -0
- data/app/controllers/devise/password_expired_controller.rb +55 -0
- data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
- data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
- data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
- data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
- data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
- data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
- data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
- data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
- data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
- data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
- data/app/controllers/mno_enterprise/status_controller.rb +27 -0
- data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
- data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
- data/app/models/mno_enterprise/health_check.rb +16 -0
- data/app/views/devise/password_expired/show.html.haml +32 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
- data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
- data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
- data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
- data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
- data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
- data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
- data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
- data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
- data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
- data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
- data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
- data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
- data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
- data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
- data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
- data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
- data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
- data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
- data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
- data/app/views/mno_enterprise/provision/new.html.haml +4 -0
- data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
- data/config/initializers/devise.rb +273 -0
- data/config/initializers/devise_extension.rb +9 -0
- data/config/initializers/devise_log.rb +12 -0
- data/config/initializers/health_check.rb +35 -0
- data/config/initializers/main_app_version.rb +6 -0
- data/config/routes.rb +152 -0
- data/lib/mno-enterprise-api.rb +1 -0
- data/lib/mno_enterprise/api.rb +14 -0
- data/lib/mno_enterprise/api/engine.rb +9 -0
- data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
- data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
- data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
- data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
- data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
- data/lib/mno_enterprise/event_logger.rb +32 -0
- data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
- data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
- data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
- data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
- data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
- data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
- data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
- data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
- data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
- data/spec/rails_helper.rb +94 -0
- data/spec/requests/devise/authentication_spec.rb +43 -0
- data/spec/requests/devise/registration_spec.rb +64 -0
- data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
- data/spec/routing/devise/passwords_routing_spec.rb +24 -0
- data/spec/routing/devise/registrations_routing_spec.rb +16 -0
- data/spec/routing/devise/sessions_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
- data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
- data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
- data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
- data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
- data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
- data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
- data/spec/spec_helper.rb +88 -0
- metadata +402 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Warden::Manager.after_authentication do |user, auth, opts|
|
|
2
|
+
MnoEnterprise::EventLogger.info('user_login', user.id, "User login", user.email, user) if user
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Warden::Manager.before_logout do |user, auth, opts|
|
|
6
|
+
# Determine whether it's a sign out or timeout
|
|
7
|
+
if auth.env['PATH_INFO'] =~ %r{^/auth/users/sign_out.json$}
|
|
8
|
+
MnoEnterprise::EventLogger.info('user_logout', user.id, "User logout", user.email, user) if user
|
|
9
|
+
else
|
|
10
|
+
MnoEnterprise::EventLogger.info('user_timeout', user.id, "User session expired", user.email, user) if user
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
HealthCheck::Engine.routes_manually_defined = true
|
|
2
|
+
|
|
3
|
+
HealthCheck.setup do |config|
|
|
4
|
+
|
|
5
|
+
# Text output upon success
|
|
6
|
+
config.success = 'success'
|
|
7
|
+
|
|
8
|
+
# Timeout in seconds used when checking smtp server
|
|
9
|
+
config.smtp_timeout = 30.0
|
|
10
|
+
|
|
11
|
+
# http status code used when plain text error message is output
|
|
12
|
+
# Set to 200 if you want your want to distinguish between partial (text does not include success) and
|
|
13
|
+
# total failure of rails application (http status of 500 etc)
|
|
14
|
+
|
|
15
|
+
config.http_status_for_error_text = 500
|
|
16
|
+
|
|
17
|
+
# http status code used when an error object is output (json or xml)
|
|
18
|
+
# Set to 200 if you want your want to distinguish between partial (healthy property == false) and
|
|
19
|
+
# total failure of rails application (http status of 500 etc)
|
|
20
|
+
|
|
21
|
+
config.http_status_for_error_object = 500
|
|
22
|
+
|
|
23
|
+
# You can customize which checks happen on a standard health check
|
|
24
|
+
config.standard_checks = [ 'database', 'migrations', 'custom' ]
|
|
25
|
+
|
|
26
|
+
# You can set what tests are run with the 'full' or 'all' parameter
|
|
27
|
+
config.full_checks = ['database', 'migrations', 'cache', 'custom']
|
|
28
|
+
|
|
29
|
+
# Add one or more custom checks that return a blank string if ok, or an error message if there is an error
|
|
30
|
+
config.add_custom_check do
|
|
31
|
+
# any code that returns blank on success and non blank string upon failure
|
|
32
|
+
MnoEnterprise::HealthCheck.perform_mno_hub_check
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Set the application version from the VERSION file in the root folder
|
|
2
|
+
version_file = "#{Rails.root}/BUILD_NUMBER"
|
|
3
|
+
git_version = `git rev-parse --short HEAD`.chomp.presence rescue nil
|
|
4
|
+
build_number = File.new(version_file).read.chomp if File.exists?(version_file)
|
|
5
|
+
|
|
6
|
+
MnoEnterprise::APP_VERSION = [build_number, git_version].compact.join('-')
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
MnoEnterprise::Engine.routes.draw do
|
|
2
|
+
# Generic routes
|
|
3
|
+
get '/launch/:id', to: 'pages#launch', constraints: {id: /[\w\-\.:]+/}
|
|
4
|
+
get '/loading/:id', to: 'pages#loading', constraints: {id: /[\w\-\.]+/}
|
|
5
|
+
get '/app_access_unauthorized', to: 'pages#app_access_unauthorized'
|
|
6
|
+
get '/billing_details_required', to: 'pages#billing_details_required'
|
|
7
|
+
get '/app_logout', to: 'pages#app_logout'
|
|
8
|
+
|
|
9
|
+
# Health Status
|
|
10
|
+
get '/ping', to: 'status#ping'
|
|
11
|
+
get '/version', to: 'status#version'
|
|
12
|
+
get 'health_check(/:checks)(.:format)', to: '/health_check/health_check#index'
|
|
13
|
+
|
|
14
|
+
# App Provisioning
|
|
15
|
+
resources :provision, only: [:new, :create]
|
|
16
|
+
|
|
17
|
+
# Organization Invites
|
|
18
|
+
resources :org_invites, only: [:show]
|
|
19
|
+
|
|
20
|
+
resources :deletion_requests, only: [:show] do
|
|
21
|
+
member do
|
|
22
|
+
patch :freeze_account
|
|
23
|
+
patch :checkout
|
|
24
|
+
put :terminate_account
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
get "/impersonate/user/:user_id", to: "impersonate#create", as: :impersonate_user
|
|
30
|
+
delete "/impersonate/revert", to: "impersonate#destroy", as: :revert_impersonate_user
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#============================================================
|
|
34
|
+
# Devise/User Configuration
|
|
35
|
+
#============================================================
|
|
36
|
+
# Main devise configuration
|
|
37
|
+
devise_for :users, {
|
|
38
|
+
class_name: "MnoEnterprise::User",
|
|
39
|
+
module: :devise,
|
|
40
|
+
path_prefix: 'auth',
|
|
41
|
+
controllers: {
|
|
42
|
+
confirmations: "mno_enterprise/auth/confirmations",
|
|
43
|
+
#omniauth_callbacks: "auth/omniauth_callbacks",
|
|
44
|
+
passwords: "mno_enterprise/auth/passwords",
|
|
45
|
+
registrations: "mno_enterprise/auth/registrations",
|
|
46
|
+
sessions: "mno_enterprise/auth/sessions",
|
|
47
|
+
unlocks: "mno_enterprise/auth/unlocks"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Additional devise routes
|
|
52
|
+
# TODO: routing specs
|
|
53
|
+
devise_scope :user do
|
|
54
|
+
get "/auth/users/confirmation/lounge", to: "auth/confirmations#lounge", as: :user_confirmation_lounge
|
|
55
|
+
patch "/auth/users/confirmation/finalize", to: "auth/confirmations#finalize", as: :user_confirmation_finalize
|
|
56
|
+
patch "/auth/users/confirmation", to: "auth/confirmations#update"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#============================================================
|
|
60
|
+
# Webhooks
|
|
61
|
+
#============================================================
|
|
62
|
+
namespace :webhook do
|
|
63
|
+
# OAuth Management
|
|
64
|
+
resources :oauth, only: [], constraints: {id: /[\w\-\.:]+/}, controller: "o_auth" do
|
|
65
|
+
member do
|
|
66
|
+
get :authorize
|
|
67
|
+
get :callback
|
|
68
|
+
get :disconnect
|
|
69
|
+
get :sync
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
#============================================================
|
|
75
|
+
# JPI V1
|
|
76
|
+
#============================================================
|
|
77
|
+
namespace :jpi do
|
|
78
|
+
namespace :v1 do
|
|
79
|
+
resources :marketplace, only: [:index, :show]
|
|
80
|
+
resource :current_user, only: [:show, :update] do
|
|
81
|
+
put :update_password
|
|
82
|
+
#post :deletion_request, action: :create_deletion_request
|
|
83
|
+
#delete :deletion_request, action: :cancel_deletion_request
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
resources :organizations, only: [:index, :show, :create, :update, :destroy] do
|
|
87
|
+
member do
|
|
88
|
+
put :update_billing
|
|
89
|
+
put :invite_members
|
|
90
|
+
put :update_member
|
|
91
|
+
put :remove_member
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# AppInstances
|
|
95
|
+
resources :app_instances, only: [:index, :destroy], shallow: true
|
|
96
|
+
|
|
97
|
+
# Teams
|
|
98
|
+
resources :teams, only: [:index, :show, :create, :update, :destroy], shallow: true do
|
|
99
|
+
member do
|
|
100
|
+
put :add_users
|
|
101
|
+
put :remove_users
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
resources :app_instances_sync, only: [:create, :index]
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
resources :deletion_requests, only: [:show, :create, :destroy] do
|
|
109
|
+
member do
|
|
110
|
+
put :resend
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
namespace :impac do
|
|
115
|
+
resources :dashboards, only: [:index, :show, :create, :update, :destroy] do
|
|
116
|
+
resources :widgets, shallow: true, only: [:create, :destroy, :update]
|
|
117
|
+
resources :kpis, shallow: true, only: [:create, :destroy, :update]
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
#============================================================
|
|
123
|
+
# Admin
|
|
124
|
+
#============================================================
|
|
125
|
+
namespace :admin, defaults: {format: 'json'} do
|
|
126
|
+
resources :audit_events, only: [:index]
|
|
127
|
+
resources :users, only: [:index, :show, :destroy, :update, :create]
|
|
128
|
+
resources :organizations, only: [:index, :show] do
|
|
129
|
+
collection do
|
|
130
|
+
get :in_arrears
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
resources :tenant_invoices, only: [:index, :show]
|
|
134
|
+
resources :invoices, only: [:index, :show] do
|
|
135
|
+
collection do
|
|
136
|
+
get :current_billing_amount
|
|
137
|
+
get :last_invoicing_amount
|
|
138
|
+
get :outstanding_amount
|
|
139
|
+
get :last_commission_amount
|
|
140
|
+
get :last_portfolio_amount
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
resources :cloud_apps, only: [:index, :update] do
|
|
144
|
+
member do
|
|
145
|
+
put :regenerate_api_key
|
|
146
|
+
put :refresh_metadata
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'mno_enterprise/api'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'action_view' # To fix "uninitialized constant Haml::ActionView"
|
|
2
|
+
require 'jbuilder'
|
|
3
|
+
require 'haml'
|
|
4
|
+
|
|
5
|
+
require 'mno_enterprise/core'
|
|
6
|
+
|
|
7
|
+
module MaestranoEnterprise
|
|
8
|
+
module Api
|
|
9
|
+
require 'mno_enterprise/api/engine'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Needs Rails::Engine to be loaded
|
|
14
|
+
require 'health_check'
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# TODO: extract the request check to filter or block?
|
|
2
|
+
module MnoEnterprise::Concerns::Controllers::DeletionRequestsController
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
#==================================================================
|
|
6
|
+
# Included methods
|
|
7
|
+
#==================================================================
|
|
8
|
+
# 'included do' causes the included code to be evaluated in the
|
|
9
|
+
# context where it is included rather than being executed in the module's context
|
|
10
|
+
included do
|
|
11
|
+
before_filter :authenticate_user!
|
|
12
|
+
before_filter :redirect_to_lounge_if_unconfirmed
|
|
13
|
+
before_filter :set_meta
|
|
14
|
+
|
|
15
|
+
def set_meta
|
|
16
|
+
@meta[:title] = "Account Termination"
|
|
17
|
+
@meta[:description] = "Account Termination"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#==================================================================
|
|
22
|
+
# Class methods
|
|
23
|
+
#==================================================================
|
|
24
|
+
module ClassMethods
|
|
25
|
+
# def some_class_method
|
|
26
|
+
# 'some text'
|
|
27
|
+
# end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#==================================================================
|
|
31
|
+
# Instance methods
|
|
32
|
+
#================================================================
|
|
33
|
+
# GET /deletion_requests/1
|
|
34
|
+
def show
|
|
35
|
+
# authorize! :manage_billing, current_user.organizations.find(@invoice.organization_id)
|
|
36
|
+
@deletion_request = current_user.deletion_request
|
|
37
|
+
|
|
38
|
+
respond_to do |format|
|
|
39
|
+
# Check that the user has a deletion_request in progress
|
|
40
|
+
# and that the token provided (params[:id]) matches the
|
|
41
|
+
# deletion_request token
|
|
42
|
+
if @deletion_request.present? && @deletion_request.token == params[:id]
|
|
43
|
+
|
|
44
|
+
# Contextual assignments
|
|
45
|
+
if ['account_frozen', 'account_checked_out'].include?(@deletion_request.status)
|
|
46
|
+
# @final_invoices = current_user.final_invoices
|
|
47
|
+
@final_invoices = []
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
format.html
|
|
51
|
+
format.json { render json: @deletion_request }
|
|
52
|
+
else
|
|
53
|
+
format.html { redirect_to main_app.root_path, alert: 'This deletion request is invalid or expired' }
|
|
54
|
+
format.json { head :bad_request }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# PATCH /deletion_requests/1/freeze_account
|
|
60
|
+
def freeze_account
|
|
61
|
+
@deletion_request = current_user.deletion_request
|
|
62
|
+
|
|
63
|
+
respond_to do |format|
|
|
64
|
+
# Check that the user has a deletion_request in progress
|
|
65
|
+
# and that the token provided (params[:id]) matches the
|
|
66
|
+
# deletion_request token
|
|
67
|
+
if @deletion_request.present? && @deletion_request.token == params[:id]
|
|
68
|
+
# Check that the deletion_request has the right status
|
|
69
|
+
if @deletion_request.status == 'pending'
|
|
70
|
+
@deletion_request.freeze_account!
|
|
71
|
+
format.html { redirect_to @deletion_request, notice: 'Your account has been frozen' }
|
|
72
|
+
else
|
|
73
|
+
format.html { redirect_to @deletion_request, alert: 'Invalid action' }
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
format.html { redirect_to main_app.root_path, alert: 'This deletion request is invalid or expired' }
|
|
77
|
+
format.json { head :bad_request }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# PATCH /deletion_requests/1/checkout
|
|
83
|
+
def checkout
|
|
84
|
+
@deletion_request = current_user.deletion_request
|
|
85
|
+
|
|
86
|
+
respond_to do |format|
|
|
87
|
+
# Check that the user has a deletion_request in progress
|
|
88
|
+
# and that the token provided (params[:id]) matches the
|
|
89
|
+
# deletion_request token
|
|
90
|
+
if @deletion_request.present? && @deletion_request.token == params[:id]
|
|
91
|
+
# Check that the deletion_request has the right status
|
|
92
|
+
if @deletion_request.status == 'account_frozen'
|
|
93
|
+
# TODO:
|
|
94
|
+
# Attempt to update the credit cards first
|
|
95
|
+
# Finally Perform the checkout
|
|
96
|
+
@deletion_request.status = 'account_checked_out'
|
|
97
|
+
@deletion_request.save
|
|
98
|
+
format.html { redirect_to @deletion_request, notice: 'Checkout has been performed successfully' }
|
|
99
|
+
else
|
|
100
|
+
format.html { redirect_to @deletion_request, alert: 'Invalid action' }
|
|
101
|
+
end
|
|
102
|
+
else
|
|
103
|
+
format.html { redirect_to main_app.root_path, alert: 'This deletion request is invalid or expired' }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::Jpi::V1::Admin::BaseResourceController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
ADMIN_CACHE_DURATION = 12.hours
|
|
11
|
+
|
|
12
|
+
before_filter :check_authorization
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
protected
|
|
16
|
+
|
|
17
|
+
def timestamp
|
|
18
|
+
@timestamp ||= (params[:timestamp] || 0).to_i
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def parent_organization
|
|
22
|
+
@parent_organization ||= current_user.organizations.to_a.find { |o| o.id.to_s == params[:organization_id].to_s }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Check current user is logged in
|
|
26
|
+
# Check organization is valid if specified
|
|
27
|
+
def check_authorization
|
|
28
|
+
if current_user && current_user.admin_role.present?
|
|
29
|
+
return true
|
|
30
|
+
end
|
|
31
|
+
render nothing: true, status: :unauthorized
|
|
32
|
+
false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::Jpi::V1::CurrentUsersController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
before_filter :authenticate_user!, only: [:update, :update_password]
|
|
11
|
+
respond_to :json
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#==================================================================
|
|
16
|
+
# Instance methods
|
|
17
|
+
#==================================================================
|
|
18
|
+
# GET /mnoe/jpi/v1/current_user
|
|
19
|
+
def show
|
|
20
|
+
@user = current_user || MnoEnterprise::User.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# PUT /mnoe/jpi/v1/current_user
|
|
24
|
+
def update
|
|
25
|
+
@user = current_user
|
|
26
|
+
|
|
27
|
+
@user.assign_attributes(user_params)
|
|
28
|
+
changes = @user.changes
|
|
29
|
+
if @user.update(user_params)
|
|
30
|
+
MnoEnterprise::EventLogger.info('user_update', current_user.id, "User update", changes, @user)
|
|
31
|
+
render :show
|
|
32
|
+
else
|
|
33
|
+
render json: @user.errors, status: :bad_request
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# PUT /mnoe/jpi/v1/current_user/update_password
|
|
38
|
+
def update_password
|
|
39
|
+
@user = current_user
|
|
40
|
+
|
|
41
|
+
if @user.update(password_params.merge(current_password_required: true))
|
|
42
|
+
MnoEnterprise::EventLogger.info('user_update_password', current_user.id, "User password change", @user.email, @user)
|
|
43
|
+
sign_in @user, bypass: true
|
|
44
|
+
render :show
|
|
45
|
+
else
|
|
46
|
+
render json: @user.errors, status: :bad_request
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
def user_params
|
|
52
|
+
params.require(:user).permit(:name, :surname, :email, :company, :settings, :phone, :website, :phone_country_code, :current_password, :password, :password_confirmation)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def password_params
|
|
56
|
+
params.require(:user).permit(:current_password, :password, :password_confirmation)
|
|
57
|
+
end
|
|
58
|
+
end
|