neeto-commons-backend 1.0.89
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintignore +14 -0
- data/.eslintrc.js +87 -0
- data/.husky/helpers/verify_neeto_audit.sh +18 -0
- data/.husky/pre-push +5 -0
- data/.neetoci/neetoci.yml +26 -0
- data/.prettierrc.js +15 -0
- data/.rubocop.yml +626 -0
- data/.ruby-version +1 -0
- data/.semaphore/semaphore.yml +32 -0
- data/.semaphore/staging-deploy.yml +23 -0
- data/Gemfile +92 -0
- data/Gemfile.lock +461 -0
- data/README.md +286 -0
- data/Rakefile +18 -0
- data/app/controllers/api/base_controller.rb +6 -0
- data/app/controllers/neeto_commons_backend/api/base_controller.rb +9 -0
- data/app/controllers/neeto_commons_backend/api/direct_uploads_controller.rb +57 -0
- data/app/controllers/neeto_commons_backend/app_versions_controller.rb +20 -0
- data/app/controllers/neeto_commons_backend/failures_controller.rb +29 -0
- data/app/controllers/neeto_commons_backend/health_check_controller.rb +9 -0
- data/app/controllers/neeto_commons_backend/well_knowns_controller.rb +13 -0
- data/app/mailers/neeto_commons_backend/application_mailer.rb +22 -0
- data/app/models/concerns/neeto_commons_backend/sluggable.rb +27 -0
- data/app/models/concerns/neeto_commons_backend/soft_deletable.rb +20 -0
- data/app/services/neeto_commons_backend/sample_data/common/admin_service.rb +26 -0
- data/app/services/neeto_commons_backend/sample_data/common/app_organization_service.rb +11 -0
- data/app/services/neeto_commons_backend/sample_data/common/base.rb +49 -0
- data/app/services/neeto_commons_backend/sample_data/common/database_cleanup_service.rb +13 -0
- data/app/services/neeto_commons_backend/sample_data/common/loader_service.rb +30 -0
- data/app/services/neeto_commons_backend/sample_data/common/neeto_team_members_service.rb +16 -0
- data/app/services/neeto_commons_backend/sample_data/common/organization_base.rb +36 -0
- data/app/services/neeto_commons_backend/sample_data/common/organization_service.rb +11 -0
- data/app/services/neeto_commons_backend/source_map_publish_service.rb +47 -0
- data/app/views/neeto_commons_backend/failures/show.html.erb +1 -0
- data/app/views/shared/_common.html.erb +8 -0
- data/app/views/shared/_neeto_engineering_replay_widget.html.erb +31 -0
- data/app/views/shared/_neeto_widget.html.erb +30 -0
- data/app/workers/neeto_commons_backend/base_workers/auth.rb +9 -0
- data/app/workers/neeto_commons_backend/base_workers/base.rb +52 -0
- data/app/workers/neeto_commons_backend/base_workers/default.rb +8 -0
- data/app/workers/neeto_commons_backend/base_workers/low.rb +9 -0
- data/app/workers/neeto_commons_backend/base_workers/urgent.rb +9 -0
- data/app/workers/neeto_commons_backend/purge_unattached_files_worker.rb +11 -0
- data/babel.config.js +47 -0
- data/bin/console +15 -0
- data/bin/rails +16 -0
- data/bin/setup +8 -0
- data/config/brakeman.ignore +52 -0
- data/config/locales/en.yml +5 -0
- data/docs/carriers/README.md +5 -0
- data/docs/controller_concerns/README.md +34 -0
- data/docs/controllers/README.md +27 -0
- data/docs/gemfiles/README.md +5 -0
- data/docs/helpers/README.md +21 -0
- data/docs/mailers/README.md +5 -0
- data/docs/model_concerns/README.md +39 -0
- data/docs/routes/README.md +44 -0
- data/docs/scripts/README.md +5 -0
- data/docs/semaphore/README.md +5 -0
- data/docs/services/README.md +23 -0
- data/docs/workers/README.md +32 -0
- data/docs/workflows/README.md +9 -0
- data/lib/Rakefile +4 -0
- data/lib/neeto-commons-backend.rb +62 -0
- data/lib/neeto_commons_backend/.circleci/config.yml +84 -0
- data/lib/neeto_commons_backend/.slugignore +17 -0
- data/lib/neeto_commons_backend/carriers/app_url_carrier.rb +71 -0
- data/lib/neeto_commons_backend/common_files/.bundler-version +1 -0
- data/lib/neeto_commons_backend/common_files/.editorconfig +10 -0
- data/lib/neeto_commons_backend/common_files/.erb-lint.yml +20 -0
- data/lib/neeto_commons_backend/common_files/.eslintignore +14 -0
- data/lib/neeto_commons_backend/common_files/.eslintrc.js +2 -0
- data/lib/neeto_commons_backend/common_files/.gitignore +132 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/lint_staged.sh +5 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/prevent_conflict_markers.sh +35 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/prevent_pushing_to_main.sh +24 -0
- data/lib/neeto_commons_backend/common_files/.husky/helpers/verify_neeto_audit.sh +17 -0
- data/lib/neeto_commons_backend/common_files/.husky/pre-commit +9 -0
- data/lib/neeto_commons_backend/common_files/.husky/pre-push +7 -0
- data/lib/neeto_commons_backend/common_files/.node-version +1 -0
- data/lib/neeto_commons_backend/common_files/.nvmrc +1 -0
- data/lib/neeto_commons_backend/common_files/.postcssrc.yml +6 -0
- data/lib/neeto_commons_backend/common_files/.prettierrc.js +1 -0
- data/lib/neeto_commons_backend/common_files/.rubocop.yml +625 -0
- data/lib/neeto_commons_backend/common_files/.ruby-version +1 -0
- data/lib/neeto_commons_backend/common_files/.semaphore/commands/run_eslint_on_modified_files.sh +5 -0
- data/lib/neeto_commons_backend/common_files/.vscode/extensions.json +10 -0
- data/lib/neeto_commons_backend/common_files/.vscode/settings.json +21 -0
- data/lib/neeto_commons_backend/common_files/Dockerfile.dev +50 -0
- data/lib/neeto_commons_backend/common_files/app/javascript/jsconfig.json +62 -0
- data/lib/neeto_commons_backend/common_files/app/javascript/src/types.d.ts +36 -0
- data/lib/neeto_commons_backend/common_files/babel.config.js +1 -0
- data/lib/neeto_commons_backend/common_files/bin/bundle +5 -0
- data/lib/neeto_commons_backend/common_files/bin/rails +6 -0
- data/lib/neeto_commons_backend/common_files/bin/rake +6 -0
- data/lib/neeto_commons_backend/common_files/bin/setup +40 -0
- data/lib/neeto_commons_backend/common_files/bin/update +33 -0
- data/lib/neeto_commons_backend/common_files/bin/webpacker +17 -0
- data/lib/neeto_commons_backend/common_files/bin/webpacker-dev-server +17 -0
- data/lib/neeto_commons_backend/common_files/bin/yarn +19 -0
- data/lib/neeto_commons_backend/common_files/cypress-tests/.eslintrc.js +57 -0
- data/lib/neeto_commons_backend/common_files/cypress-tests/cypress/plugins/index.js +63 -0
- data/lib/neeto_commons_backend/common_files/github/workflows/auto_update_prs_with_latest_master.yml +21 -0
- data/lib/neeto_commons_backend/common_files/neeto_gems/github/workflows/bump_version.yml +51 -0
- data/lib/neeto_commons_backend/common_files/newrelic.yml +31 -0
- data/lib/neeto_commons_backend/common_files/package-common.json +119 -0
- data/lib/neeto_commons_backend/common_files/roles.yml +34 -0
- data/lib/neeto_commons_backend/common_files/semaphore/semaphore.yml +58 -0
- data/lib/neeto_commons_backend/common_files/sitemap.xml +15 -0
- data/lib/neeto_commons_backend/common_files/test/support/assertion_support.rb +9 -0
- data/lib/neeto_commons_backend/common_files/webpacker.yml +90 -0
- data/lib/neeto_commons_backend/config/secrets.yml +169 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_exceptions.rb +83 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_helpers.rb +9 -0
- data/lib/neeto_commons_backend/controllers/concerns/api_responders.rb +33 -0
- data/lib/neeto_commons_backend/controllers/concerns/authenticatable.rb +51 -0
- data/lib/neeto_commons_backend/controllers/concerns/honeybadger_context.rb +17 -0
- data/lib/neeto_commons_backend/controllers/concerns/store_user_location.rb +23 -0
- data/lib/neeto_commons_backend/cypress/cypress.review.json +13 -0
- data/lib/neeto_commons_backend/cypress/jsconfig.json +17 -0
- data/lib/neeto_commons_backend/cypress/package.json +51 -0
- data/lib/neeto_commons_backend/cypress/resolve.js +16 -0
- data/lib/neeto_commons_backend/cypress/webpack.config.js +21 -0
- data/lib/neeto_commons_backend/engine.rb +6 -0
- data/lib/neeto_commons_backend/environments/application.rb +33 -0
- data/lib/neeto_commons_backend/environments/development.rb +46 -0
- data/lib/neeto_commons_backend/environments/heroku.rb +35 -0
- data/lib/neeto_commons_backend/environments/production.rb +45 -0
- data/lib/neeto_commons_backend/environments/staging.rb +43 -0
- data/lib/neeto_commons_backend/environments/test.rb +29 -0
- data/lib/neeto_commons_backend/gemfiles/Gemfile.common.rb +240 -0
- data/lib/neeto_commons_backend/helpers/auth_server_api.rb +92 -0
- data/lib/neeto_commons_backend/helpers/favicon.rb +18 -0
- data/lib/neeto_commons_backend/helpers/global_props.rb +76 -0
- data/lib/neeto_commons_backend/helpers/neeto_widget_helper.rb +19 -0
- data/lib/neeto_commons_backend/helpers/test_helper.rb +90 -0
- data/lib/neeto_commons_backend/initializers/_enable_extension_hack.rb +32 -0
- data/lib/neeto_commons_backend/initializers/assets.rb +11 -0
- data/lib/neeto_commons_backend/initializers/bullet.rb +26 -0
- data/lib/neeto_commons_backend/initializers/cache_store.rb +27 -0
- data/lib/neeto_commons_backend/initializers/common.rb +33 -0
- data/lib/neeto_commons_backend/initializers/cookies_serializer.rb +11 -0
- data/lib/neeto_commons_backend/initializers/cors.rb +16 -0
- data/lib/neeto_commons_backend/initializers/database_cleaner.rb +11 -0
- data/lib/neeto_commons_backend/initializers/datetime.rb +14 -0
- data/lib/neeto_commons_backend/initializers/email_setup.rb +25 -0
- data/lib/neeto_commons_backend/initializers/filter_parameter_logging.rb +11 -0
- data/lib/neeto_commons_backend/initializers/honeybadger.rb +23 -0
- data/lib/neeto_commons_backend/initializers/kaminari_config.rb +13 -0
- data/lib/neeto_commons_backend/initializers/mime_types.rb +12 -0
- data/lib/neeto_commons_backend/initializers/mini_profiler.rb +14 -0
- data/lib/neeto_commons_backend/initializers/neeto_email_prefixer.rb +40 -0
- data/lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb +35 -0
- data/lib/neeto_commons_backend/initializers/post_compilation.rb +17 -0
- data/lib/neeto_commons_backend/initializers/rack_attack.rb +38 -0
- data/lib/neeto_commons_backend/initializers/rack_deflater.rb +11 -0
- data/lib/neeto_commons_backend/initializers/rack_timeout.rb +15 -0
- data/lib/neeto_commons_backend/initializers/rails_email_preview.rb +21 -0
- data/lib/neeto_commons_backend/initializers/redis_client_patch.rb +18 -0
- data/lib/neeto_commons_backend/initializers/remove_backtrace_silencers.rb +11 -0
- data/lib/neeto_commons_backend/initializers/session_store.rb +21 -0
- data/lib/neeto_commons_backend/initializers/shared_redis.rb +13 -0
- data/lib/neeto_commons_backend/initializers/sidekiq.rb +46 -0
- data/lib/neeto_commons_backend/initializers/strong_migrations.rb +13 -0
- data/lib/neeto_commons_backend/initializers/wrap_parameters.rb +13 -0
- data/lib/neeto_commons_backend/models/concerns/devise_validator.rb +19 -0
- data/lib/neeto_commons_backend/railtie.rb +20 -0
- data/lib/neeto_commons_backend/routes/catch_all.rb +9 -0
- data/lib/neeto_commons_backend/routes/devise.rb +16 -0
- data/lib/neeto_commons_backend/routes/direct_uploads.rb +9 -0
- data/lib/neeto_commons_backend/routes/draw.rb +29 -0
- data/lib/neeto_commons_backend/routes/email_previews.rb +5 -0
- data/lib/neeto_commons_backend/routes/errors.rb +7 -0
- data/lib/neeto_commons_backend/routes/health.rb +8 -0
- data/lib/neeto_commons_backend/routes/letter_opener.rb +5 -0
- data/lib/neeto_commons_backend/routes/sidekiq.rb +22 -0
- data/lib/neeto_commons_backend/routes/well_knowns.rb +10 -0
- data/lib/neeto_commons_backend/scripts/sync_with_wheel.sh +54 -0
- data/lib/neeto_commons_backend/secrets_management.rb +41 -0
- data/lib/neeto_commons_backend/services/custom_domain_service.rb +40 -0
- data/lib/neeto_commons_backend/tasks/assets.rake +27 -0
- data/lib/neeto_commons_backend/tasks/before_assets_precompile.rake +13 -0
- data/lib/neeto_commons_backend/tasks/simplecov_coverage.rake +25 -0
- data/lib/neeto_commons_backend/version.rb +5 -0
- data/neeto-commons-backend.gemspec +52 -0
- data/package.json +31 -0
- data/yarn.lock +2530 -0
- metadata +497 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
const resolve = require("./resolve");
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
resolve,
|
5
|
+
module: {
|
6
|
+
rules: [
|
7
|
+
{
|
8
|
+
test: /\.(js|jsx)$/,
|
9
|
+
exclude: [/node_modules/],
|
10
|
+
use: [
|
11
|
+
{
|
12
|
+
loader: "babel-loader",
|
13
|
+
options: {
|
14
|
+
presets: ["@babel/preset-env"],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
],
|
18
|
+
},
|
19
|
+
],
|
20
|
+
},
|
21
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def application(config, routes = nil)
|
7
|
+
config.load_defaults 7.0
|
8
|
+
config.serve_static_assets = true
|
9
|
+
config.action_controller.raise_on_open_redirects = false
|
10
|
+
config.active_storage.variant_processor = :mini_magick
|
11
|
+
config.active_storage.service_urls_expire_in = 1.hour
|
12
|
+
config.exceptions_app = routes unless routes.nil?
|
13
|
+
|
14
|
+
config.active_record.encryption.primary_key = Rails.application.secrets.encryption[:primary_key]
|
15
|
+
config.active_record.encryption.deterministic_key = Rails.application.secrets.encryption[:deterministic_key]
|
16
|
+
config.active_record.encryption.key_derivation_salt = Rails.application.secrets.encryption[:key_derivation_salt]
|
17
|
+
|
18
|
+
config.active_job.queue_adapter = :sidekiq
|
19
|
+
config.active_job.default_queue_name = :default
|
20
|
+
config.action_mailer.deliver_later_queue_name = :default
|
21
|
+
config.active_storage.queues.analysis = :low
|
22
|
+
config.active_storage.queues.purge = :low
|
23
|
+
config.action_mailbox.queues.routing = :default
|
24
|
+
config.action_mailbox.queues.incineration = :low
|
25
|
+
|
26
|
+
NeetoCommonsBackend::Initializers.cache_store(config)
|
27
|
+
config.generators do |generator|
|
28
|
+
generator.orm :active_record, primary_key_type: :uuid
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def development(config)
|
7
|
+
config.cache_classes = false
|
8
|
+
config.eager_load = false
|
9
|
+
config.consider_all_requests_local = true
|
10
|
+
config.active_storage.service = :local
|
11
|
+
|
12
|
+
url_options = {
|
13
|
+
host: "http://app.#{ENV["LOCALHOST_DOMAIN"]}",
|
14
|
+
port: Rails.application.secrets.server_port
|
15
|
+
}
|
16
|
+
Rails.application.routes.default_url_options = url_options
|
17
|
+
config.action_mailer.default_url_options = url_options
|
18
|
+
config.action_mailer.delivery_method = :letter_opener
|
19
|
+
config.action_mailer.perform_deliveries = true
|
20
|
+
config.action_mailer.raise_delivery_errors = false
|
21
|
+
config.action_mailer.perform_caching = false
|
22
|
+
config.active_support.deprecation = :log
|
23
|
+
config.active_support.disallowed_deprecation = :raise
|
24
|
+
config.active_support.disallowed_deprecation_warnings = []
|
25
|
+
config.active_record.migration_error = :page_load
|
26
|
+
config.active_record.verbose_query_logs = true
|
27
|
+
config.assets.quiet = true
|
28
|
+
config.server_timing = true
|
29
|
+
config.i18n.raise_on_missing_translations = true
|
30
|
+
config.webpacker.check_yarn_integrity = true
|
31
|
+
config.hosts << /\A[*a-zA-Z0-9\-_]+\.*.*\z|\A*.*\z/
|
32
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
33
|
+
config.action_controller.perform_caching = true
|
34
|
+
config.action_controller.enable_fragment_cache_logging = true
|
35
|
+
config.cache_store = :memory_store
|
36
|
+
config.public_file_server.headers = {
|
37
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
38
|
+
}
|
39
|
+
else
|
40
|
+
config.action_controller.perform_caching = false
|
41
|
+
config.cache_store = :null_store
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def heroku(config)
|
7
|
+
config.cache_classes = true
|
8
|
+
config.eager_load = true
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_mailer.delivery_method = :letter_opener_web
|
11
|
+
config.action_mailer.perform_deliveries = true
|
12
|
+
config.action_mailer.perform_caching = false
|
13
|
+
config.action_controller.perform_caching = true
|
14
|
+
config.action_controller.forgery_protection_origin_check = false
|
15
|
+
config.public_file_server.enabled = true
|
16
|
+
config.assets.js_compressor = Uglifier.new(harmony: true)
|
17
|
+
config.assets.compile = false
|
18
|
+
config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
|
19
|
+
config.log_level = :debug
|
20
|
+
config.log_tags = [:request_id]
|
21
|
+
config.log_formatter = ::Logger::Formatter.new
|
22
|
+
config.i18n.fallbacks = true
|
23
|
+
config.active_support.deprecation = :notify
|
24
|
+
config.active_record.dump_schema_after_migration = false
|
25
|
+
if Rails.application.secrets.asset_host.present?
|
26
|
+
config.action_controller.asset_host = Rails.application.secrets.asset_host
|
27
|
+
end
|
28
|
+
if Rails.application.secrets.web_socket_server_url.present?
|
29
|
+
config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
|
30
|
+
end
|
31
|
+
config.action_cable.disable_request_forgery_protection = true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def production(config)
|
7
|
+
config.cache_classes = true
|
8
|
+
config.eager_load = true
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_mailer.delivery_method = :smtp
|
11
|
+
config.action_mailer.perform_deliveries = true
|
12
|
+
config.action_controller.perform_caching = true
|
13
|
+
config.assets.js_compressor = Uglifier.new(harmony: true)
|
14
|
+
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
15
|
+
config.assets.compile = false
|
16
|
+
if Rails.application.secrets.asset_host.present?
|
17
|
+
config.action_controller.asset_host = Rails.application.secrets.asset_host
|
18
|
+
end
|
19
|
+
|
20
|
+
config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
|
21
|
+
config.force_ssl = true
|
22
|
+
config.log_level = Rails.application.secrets.log_level
|
23
|
+
config.log_tags = [:request_id]
|
24
|
+
config.action_mailer.perform_caching = false
|
25
|
+
config.i18n.fallbacks = true
|
26
|
+
config.active_support.report_deprecations = false
|
27
|
+
config.log_formatter = ::Logger::Formatter.new
|
28
|
+
config.active_record.dump_schema_after_migration = false
|
29
|
+
config.action_controller.forgery_protection_origin_check = false
|
30
|
+
|
31
|
+
config.action_cable.disable_request_forgery_protection = true
|
32
|
+
if Rails.application.secrets.web_socket_server_url.present?
|
33
|
+
config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
|
34
|
+
config.action_cable.url = Rails.application.secrets.web_socket_server_url
|
35
|
+
end
|
36
|
+
|
37
|
+
config.public_file_server.enabled = true
|
38
|
+
config.public_file_server.headers = {
|
39
|
+
"Access-Control-Allow-Origin" => "*",
|
40
|
+
"Cache-Control" => "public, max-age=31536000"
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def staging(config)
|
7
|
+
config.cache_classes = true
|
8
|
+
config.eager_load = true
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_mailer.delivery_method = :smtp
|
11
|
+
config.action_mailer.perform_deliveries = true
|
12
|
+
config.action_controller.perform_caching = true
|
13
|
+
config.assets.js_compressor = Uglifier.new(harmony: true)
|
14
|
+
config.assets.compile = false
|
15
|
+
config.assets.digest = true
|
16
|
+
config.force_ssl = true
|
17
|
+
config.log_level = :debug
|
18
|
+
config.active_storage.service = ENV["AWS_BUCKET_NAME"].present? ? :amazon : :local
|
19
|
+
config.log_tags = [:request_id]
|
20
|
+
config.i18n.fallbacks = true
|
21
|
+
config.active_support.report_deprecations = false
|
22
|
+
config.log_formatter = ::Logger::Formatter.new
|
23
|
+
config.active_record.dump_schema_after_migration = false
|
24
|
+
config.action_controller.forgery_protection_origin_check = false
|
25
|
+
if Rails.application.secrets.asset_host.present?
|
26
|
+
config.action_controller.asset_host = Rails.application.secrets.asset_host
|
27
|
+
end
|
28
|
+
|
29
|
+
config.action_cable.disable_request_forgery_protection = true
|
30
|
+
if Rails.application.secrets.web_socket_server_url.present?
|
31
|
+
config.web_socket_server_url = Rails.application.secrets.web_socket_server_url
|
32
|
+
config.action_cable.url = Rails.application.secrets.web_socket_server_url
|
33
|
+
end
|
34
|
+
|
35
|
+
config.public_file_server.enabled = true
|
36
|
+
config.public_file_server.headers = {
|
37
|
+
"Access-Control-Allow-Origin" => "*",
|
38
|
+
"Cache-Control" => "public, max-age=31536000"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Environments
|
5
|
+
class << self
|
6
|
+
def test(config)
|
7
|
+
config.consider_all_requests_local = true
|
8
|
+
config.cache_classes = true
|
9
|
+
config.cache_store = :memory_store
|
10
|
+
config.eager_load = false
|
11
|
+
config.action_controller.perform_caching = false
|
12
|
+
config.action_mailer.perform_caching = false
|
13
|
+
config.action_mailer.delivery_method = :test
|
14
|
+
config.action_mailer.perform_deliveries = true
|
15
|
+
config.public_file_server.enabled = true
|
16
|
+
config.public_file_server.headers = {
|
17
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
18
|
+
}
|
19
|
+
config.action_dispatch.show_exceptions = false
|
20
|
+
config.action_controller.allow_forgery_protection = false
|
21
|
+
config.active_storage.service = :test
|
22
|
+
config.active_support.deprecation = :stderr
|
23
|
+
config.active_support.disallowed_deprecation = :raise
|
24
|
+
config.active_support.disallowed_deprecation_warnings = []
|
25
|
+
config.i18n.raise_on_missing_translations = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
|
5
|
+
source "https://rubygems.org"
|
6
|
+
|
7
|
+
ruby "3.2.2"
|
8
|
+
|
9
|
+
source "https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com" do
|
10
|
+
# Permanent deletion of organization and all its related models
|
11
|
+
gem "neeto-org-incineration-engine"
|
12
|
+
|
13
|
+
# Adds prefix to subject in emails
|
14
|
+
gem "neeto-email-prefixer"
|
15
|
+
|
16
|
+
# Configure SSO with neetoAuth
|
17
|
+
gem "neeto-sso"
|
18
|
+
|
19
|
+
# neeto_emails gem for email templating
|
20
|
+
gem "neeto-emails"
|
21
|
+
|
22
|
+
# neeto_commons_backend gem for methods and modules that are used across all neeto products.
|
23
|
+
gem "neeto-commons-backend"
|
24
|
+
|
25
|
+
# A light gem for superadmin interface
|
26
|
+
gem "neeto-area51-engine"
|
27
|
+
|
28
|
+
# Rails engine that serves team-members module for all Neeto apps
|
29
|
+
gem "neeto-team-members-engine"
|
30
|
+
|
31
|
+
# Rails engine that serves payments module for all Neeto apps
|
32
|
+
gem "neeto-payments-engine"
|
33
|
+
|
34
|
+
# For notifications
|
35
|
+
gem "neeto-notifications-engine"
|
36
|
+
|
37
|
+
# Rails engine that generates migrations, provide models and helpers for adding tags
|
38
|
+
gem "neeto-tags-engine"
|
39
|
+
|
40
|
+
# Rails engine that provides helpers to filter records.
|
41
|
+
gem "neeto-filters-engine"
|
42
|
+
|
43
|
+
# Rails engine that generates migrations, provide models and helpers for managing custom domains
|
44
|
+
gem "neeto-custom-domains-engine"
|
45
|
+
|
46
|
+
# Intercepts outgoing emails in non-production environment
|
47
|
+
gem "neeto-mail-interceptor"
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
gem "autoprefixer-rails"
|
52
|
+
|
53
|
+
gem "rails", "7.0.4"
|
54
|
+
|
55
|
+
gem "dotenv-rails"
|
56
|
+
|
57
|
+
# Related to AssetPipeline
|
58
|
+
gem "uglifier"
|
59
|
+
|
60
|
+
gem "shakapacker", "6.5.2"
|
61
|
+
|
62
|
+
# To use AWS S3 as backend for ActiveStorage
|
63
|
+
gem "aws-sdk-s3", require: false
|
64
|
+
|
65
|
+
# database
|
66
|
+
gem "pg"
|
67
|
+
|
68
|
+
# JSON builder
|
69
|
+
gem "jbuilder"
|
70
|
+
|
71
|
+
# Authentication
|
72
|
+
gem "devise"
|
73
|
+
|
74
|
+
# Google Authentication
|
75
|
+
gem "omniauth-google-oauth2", "0.8.1"
|
76
|
+
|
77
|
+
# Background jobs
|
78
|
+
gem "sidekiq", "7.0.8"
|
79
|
+
|
80
|
+
# For periodic jobs on sidekiq
|
81
|
+
gem "sidekiq-cron"
|
82
|
+
|
83
|
+
# For seeing failed jobs in sidekiq
|
84
|
+
gem "sidekiq-failures"
|
85
|
+
|
86
|
+
# Error tracking
|
87
|
+
gem "honeybadger"
|
88
|
+
|
89
|
+
# Application server
|
90
|
+
gem "puma"
|
91
|
+
|
92
|
+
# Authorization
|
93
|
+
gem "pundit"
|
94
|
+
|
95
|
+
# convert email css to inline
|
96
|
+
gem "premailer-rails"
|
97
|
+
|
98
|
+
# Rails request timeout, needed if running on Heroku-
|
99
|
+
# https://devcenter.heroku.com/articles/request-timeout
|
100
|
+
gem "rack-timeout", require: "rack/timeout/base"
|
101
|
+
|
102
|
+
# Rack attack gem for DDOS attacks
|
103
|
+
gem "rack-attack"
|
104
|
+
|
105
|
+
# Faster env load times
|
106
|
+
gem "bootsnap"
|
107
|
+
|
108
|
+
# For cache store
|
109
|
+
# Upgrade once Sidekiq has been upgraded from 6.5.5 and deprecation warnings are gone. https://snipboard.io/PuDU4G.jpg
|
110
|
+
gem "redis", "4.7.1"
|
111
|
+
|
112
|
+
# Memcached store adapter
|
113
|
+
gem "dalli"
|
114
|
+
|
115
|
+
# Generate fake data
|
116
|
+
gem "faker"
|
117
|
+
|
118
|
+
# I18n Internationalization
|
119
|
+
gem "rails-i18n"
|
120
|
+
|
121
|
+
# To inject React components in views and pass props from server
|
122
|
+
gem "react-rails"
|
123
|
+
|
124
|
+
# To add soft delete option to ActiveRecord
|
125
|
+
gem "paranoia"
|
126
|
+
|
127
|
+
# Pagination
|
128
|
+
gem "kaminari", "~> 1.2"
|
129
|
+
|
130
|
+
# Application Perfomance Monitoring
|
131
|
+
gem "newrelic_rpm"
|
132
|
+
|
133
|
+
# Image processing
|
134
|
+
gem "mini_magick"
|
135
|
+
|
136
|
+
# Email previews for Actionmailer
|
137
|
+
gem "rails_email_preview"
|
138
|
+
|
139
|
+
# Cross-Origin Resource Sharing (CORS) for Rack compatible web applications
|
140
|
+
# Locked to this version to fix the double headers issue. Ref: https://github.com/bigbinary/neeto-auth-web/pull/2759
|
141
|
+
gem "rack-cors", "1.1.1", require: "rack/cors"
|
142
|
+
|
143
|
+
# ActiveRecord Session Store
|
144
|
+
gem "activerecord-session_store"
|
145
|
+
|
146
|
+
# To fix uninitialized constant Mail::TestMailer with ruby 3.1.2
|
147
|
+
gem "net-smtp" # to send email
|
148
|
+
gem "net-imap" # for rspec
|
149
|
+
gem "net-pop" # for rspec
|
150
|
+
|
151
|
+
# Catch unsafe migrations in development
|
152
|
+
gem "strong_migrations"
|
153
|
+
|
154
|
+
group :development do
|
155
|
+
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
156
|
+
gem "web-console"
|
157
|
+
|
158
|
+
# A Ruby static code analyzer, based on the community Ruby style guide
|
159
|
+
gem "rubocop", require: false
|
160
|
+
|
161
|
+
gem "rubocop-minitest"
|
162
|
+
|
163
|
+
# A RuboCop extension focused on enforcing Rails best practices and coding conventions.
|
164
|
+
gem "rubocop-rails", require: false
|
165
|
+
|
166
|
+
# For linting ERB files
|
167
|
+
gem "erb_lint", require: false, git: "https://github.com/Shopify/erb-lint.git", branch: "main"
|
168
|
+
|
169
|
+
# Patch-level verification for Bundler.
|
170
|
+
gem "bundler-audit", require: false
|
171
|
+
|
172
|
+
# vulnerabity checker for Ruby itself.
|
173
|
+
gem "ruby_audit", require: false
|
174
|
+
|
175
|
+
gem "rack-mini-profiler"
|
176
|
+
|
177
|
+
# For checkking security vulnerabilities
|
178
|
+
gem "brakeman"
|
179
|
+
end
|
180
|
+
|
181
|
+
group :development, :heroku do
|
182
|
+
# For testing the mail locally
|
183
|
+
gem "letter_opener"
|
184
|
+
|
185
|
+
# For testing the emails in the browser, works with `letter_opener`
|
186
|
+
gem "letter_opener_web", "~> 2.0"
|
187
|
+
end
|
188
|
+
|
189
|
+
group :development, :test do
|
190
|
+
# To replace using fixures
|
191
|
+
gem "factory_bot_rails"
|
192
|
+
|
193
|
+
# reports N+1 queries
|
194
|
+
gem "bullet"
|
195
|
+
|
196
|
+
gem "awesome_print"
|
197
|
+
|
198
|
+
# Adds step-by-step debugging and stack navigation capabilities to pry using byebug.
|
199
|
+
# supports both syntax - pry and byebug
|
200
|
+
gem "pry-byebug"
|
201
|
+
|
202
|
+
source "https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com" do
|
203
|
+
gem "neeto-compliance"
|
204
|
+
end
|
205
|
+
|
206
|
+
gem "wkhtmltopdf-binary"
|
207
|
+
|
208
|
+
# Complete suite of testing facilities
|
209
|
+
gem "minitest"
|
210
|
+
end
|
211
|
+
|
212
|
+
group :test do
|
213
|
+
# Test coverage
|
214
|
+
gem "simplecov", require: false
|
215
|
+
|
216
|
+
# for stubbing and setting expectations on HTTP requests
|
217
|
+
gem "webmock"
|
218
|
+
|
219
|
+
# To mock and stub objects in tests
|
220
|
+
gem "mocha"
|
221
|
+
|
222
|
+
gem "minitest-reporters"
|
223
|
+
|
224
|
+
# Records test results and generates XML files.
|
225
|
+
gem "minitest-ci"
|
226
|
+
|
227
|
+
# helps you isolate and debug random test failures.
|
228
|
+
gem "minitest-bisect"
|
229
|
+
end
|
230
|
+
|
231
|
+
group :development, :staging, :heroku, :test do
|
232
|
+
gem "database_cleaner"
|
233
|
+
end
|
234
|
+
|
235
|
+
group :production do
|
236
|
+
# This gem works together with the Judoscale Heroku add-on
|
237
|
+
# to automatically scale web and worker dynos
|
238
|
+
gem "judoscale-rails", "1.3.1"
|
239
|
+
gem "judoscale-sidekiq"
|
240
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
|
5
|
+
class NeetoCommonsBackend::Helpers::AuthServerApi
|
6
|
+
MAX_RETRIES = 5
|
7
|
+
REQUEST_CLASSES = {
|
8
|
+
get: Net::HTTP::Get,
|
9
|
+
post: Net::HTTP::Post,
|
10
|
+
put: Net::HTTP::Put,
|
11
|
+
delete: Net::HTTP::Delete
|
12
|
+
}
|
13
|
+
attr_reader :endpoint, :request_body, :request_class, :request_params, :custom_headers
|
14
|
+
|
15
|
+
def initialize(custom_headers: {})
|
16
|
+
@custom_headers = custom_headers
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(**args)
|
20
|
+
request(type: :get, **args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def put(**args)
|
24
|
+
request(type: :put, **args)
|
25
|
+
end
|
26
|
+
|
27
|
+
def post(**args)
|
28
|
+
request(type: :post, **args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(**args)
|
32
|
+
request(type: :delete, **args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def request(type:, **args)
|
36
|
+
return if Rails.env.heroku?
|
37
|
+
|
38
|
+
@request_class = REQUEST_CLASSES[type]
|
39
|
+
process(**args)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def process(endpoint:, params: nil, body: nil)
|
45
|
+
@endpoint = endpoint
|
46
|
+
@request_params = params
|
47
|
+
@request_body = body
|
48
|
+
begin
|
49
|
+
retry_count ||= 0
|
50
|
+
send_request
|
51
|
+
rescue StandardError => exception
|
52
|
+
if retry_count < MAX_RETRIES
|
53
|
+
retry_count += 1
|
54
|
+
Rails.logger.warn "Error: #{exception.message}. Retrying in #{2**retry_count} seconds."
|
55
|
+
sleep 2**retry_count
|
56
|
+
retry
|
57
|
+
else
|
58
|
+
Rails.logger.error "Retries exhausted"
|
59
|
+
raise exception
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def send_request
|
65
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
66
|
+
http.use_ssl = true if uri.scheme == "https"
|
67
|
+
|
68
|
+
request = request_class.new(uri.request_uri, headers)
|
69
|
+
if request_body.present?
|
70
|
+
request.body = request_body.to_json
|
71
|
+
end
|
72
|
+
response = http.request(request)
|
73
|
+
response.body
|
74
|
+
end
|
75
|
+
|
76
|
+
def uri
|
77
|
+
return @uri if @uri.present?
|
78
|
+
|
79
|
+
@uri = URI.parse("#{Rails.application.secrets.auth_app[:url]}/api/v1/server/#{endpoint}")
|
80
|
+
if request_params.present?
|
81
|
+
@uri.query = URI.encode_www_form(request_params)
|
82
|
+
end
|
83
|
+
@uri
|
84
|
+
end
|
85
|
+
|
86
|
+
def headers
|
87
|
+
{
|
88
|
+
"Content-Type" => "application/json",
|
89
|
+
"AUTHORIZATION" => "Token token=#{Rails.application.secrets.server_authorization_token}"
|
90
|
+
}.merge(custom_headers)
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Helpers
|
5
|
+
class << self
|
6
|
+
include ActionView::Helpers::AssetUrlHelper
|
7
|
+
include ActionView::Helpers::AssetTagHelper
|
8
|
+
|
9
|
+
def favicon(organization)
|
10
|
+
if organization&.favicon_url&.present?
|
11
|
+
favicon_link_tag organization.favicon_url
|
12
|
+
else
|
13
|
+
favicon_link_tag "/favicon.ico"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoCommonsBackend
|
4
|
+
module Helpers
|
5
|
+
class << self
|
6
|
+
attr_reader :current_user, :organization
|
7
|
+
|
8
|
+
def common_client_props(organization, current_user)
|
9
|
+
@organization = organization
|
10
|
+
@current_user = current_user
|
11
|
+
@neeto_data = neeto_data if current_user.present?
|
12
|
+
|
13
|
+
global_props = {
|
14
|
+
rails_env: Rails.env,
|
15
|
+
honeybadger_api_key: ENV["HONEYBADGER_JS_API_KEY"] || ENV["HONEYBADGER_API_KEY"],
|
16
|
+
honeybadger_revision: ENV["HEROKU_SLUG_COMMIT"],
|
17
|
+
organization: organization&.as_json(only: %i[name subdomain favicon_url]),
|
18
|
+
authenticated: current_user.present?,
|
19
|
+
app_name: build_app_name
|
20
|
+
}
|
21
|
+
|
22
|
+
user_props = if current_user.present?
|
23
|
+
{
|
24
|
+
user: current_user.as_json.merge(
|
25
|
+
authentication_token: current_user.authentication_token,
|
26
|
+
date_format: current_user.date_format ? current_user.date_format_before_type_cast.upcase : "DD/MM/YYYY"
|
27
|
+
),
|
28
|
+
neeto_apps: user_data(:neeto_apps),
|
29
|
+
is_owner: user_data(:is_owner),
|
30
|
+
permissions: user_permissions
|
31
|
+
}
|
32
|
+
else
|
33
|
+
{}
|
34
|
+
end
|
35
|
+
|
36
|
+
global_props.merge(user_props)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def user_permissions
|
42
|
+
current_user_role = current_user.organization_role
|
43
|
+
return [] if current_user_role.nil?
|
44
|
+
|
45
|
+
Rails.cache.fetch("#{organization.cache_key}/#{current_user_role.cache_key_with_version}/permissions") do
|
46
|
+
current_user_role.permissions.pluck(:name) || []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def user_data(entity)
|
51
|
+
@neeto_data.with_indifferent_access[entity]
|
52
|
+
end
|
53
|
+
|
54
|
+
def neeto_data
|
55
|
+
if Rails.env.test? || Rails.env.heroku? || Rails.env.development?
|
56
|
+
{ neeto_apps: [], is_owner: true }
|
57
|
+
else
|
58
|
+
Organizations::NeetoAppsService.new(current_user).process || {
|
59
|
+
neeto_apps: [],
|
60
|
+
is_owner: false
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_app_name
|
66
|
+
client_app_name = Rails.application.secrets.client_app_name
|
67
|
+
|
68
|
+
unless client_app_name
|
69
|
+
raise "client_app_name not found. Please add client_app_name field in secrets.yml file."
|
70
|
+
end
|
71
|
+
|
72
|
+
"neeto" + client_app_name
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|