From 11e15f38405e4d4befa46e8270d297b2205a7afc Mon Sep 17 00:00:00 2001 From: wpramio Date: Wed, 31 Jan 2024 17:44:42 -0300 Subject: [PATCH] feat: several fixes for production environment --- app/controllers/application_controller.rb | 2 +- app/controllers/apps_controller.rb | 5 +++-- config/environments/production.rb | 2 +- docker-compose.yml | 8 +++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bcb6d0d7..20287bbd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base rescue_from ActionController::RoutingError, with: :on404 rescue_from ActiveRecord::RecordNotFound, with: :on404 rescue_from ActionController::UnknownFormat, with: :on406 - rescue_from ApplicationController::InvalidAuthenticityToken, with: :on406 + rescue_from ActionController::InvalidAuthenticityToken, with: :on406 end protect_from_forgery with: :exception diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index a38257f9..57f70c64 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -18,19 +18,20 @@ class AppsController < ApplicationController before_action :print_parameters if Rails.configuration.developer_mode_enabled + # skip Rails default verify auth token - we use our own strategies + skip_before_action :verify_authenticity_token # verified oauth, etc # launch into lti application def launch # Make launch request to LTI-APP - tool = RailsLti2Provider::Tool.where(uuid: params[:oauth_consumer_key]).last lti_launch = RailsLti2Provider::LtiLaunch.find_by(nonce: params[:oauth_nonce]) # add the oauth key to the data of this launch message = lti_launch.message message.custom_params['oauth_consumer_key'] = params[:oauth_consumer_key] - lti_launch.update(tool_id: tool.id, message: message.to_json) + lti_launch.update(message: message.to_json) redirector = "#{lti_app_url(params[:app])}?#{{ launch_nonce: lti_launch.nonce }.to_query}" logger.info("redirect_post to LTI app url=#{redirector}") diff --git a/config/environments/production.rb b/config/environments/production.rb index 59bfd543..b78a104e 100755 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -148,7 +148,7 @@ reconnect_attempts: 1, # Defaults to 0 error_handler: lambda { |method:, returning:, exception:| - config.logger.warn("Support: Redis cache action #{method} failed and returned '#{returning}': #{exception}") + Rails.logger.warn("Support: Redis cache action #{method} failed and returned '#{returning}': #{exception}") }, },] else [:file_store, Rails.root.join('tmp/cache_store')] diff --git a/docker-compose.yml b/docker-compose.yml index d5112b40..4f768186 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,22 +48,24 @@ services: env_file: - ./.env environment: + DISABLE_DATABASE_ENVIRONMENT_CHECK: 1 DATABASE_URL: ${DATABASE_URL:-postgresql://postgres:password@postgres:5432/lti_broker} RAILS_ENV: production + REDIS_URL: redis://:BCsy8zMwZay669ii@broker_redis:6379/0 MCONF_REDIS_HOST: broker_redis MCONF_REDIS_PASSWORD: BCsy8zMwZay669ii MCONF_REDIS_PORT: 6379 MCONF_REDIS_DB: 0 PROMETHEUS_EXPORTER_HOST: prod_exporter PROMETHEUS_EXPORTER_PORT: 9394 - WEB_CONCURRENCY: 1 + PUMA_WORKERS: 1 + LOGRAGE_ENABLED: 1 volumes: - .:/usr/src/app ports: - "3000:3000" - links: - - postgres depends_on: + - postgres - broker_redis - prod_exporter