Skip to content

Commit

Permalink
refactor: Use blazer-plus gem
Browse files Browse the repository at this point in the history
  • Loading branch information
aki77 committed Nov 8, 2023
1 parent ee6e60e commit c6c20e1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 49 deletions.
95 changes: 95 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,73 @@ PATH
sg_fargate_rails (0.1.11)
aws-sdk-ec2 (~> 1.413)
aws-sdk-scheduler (~> 1.10)
blazer-plus
lograge (~> 0.12)
puma

GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4.2)
actionpack (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activesupport (= 7.0.4.2)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4.2)
actionview (= 7.0.4.2)
activesupport (= 7.0.4.2)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4.2)
actionpack (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4.2)
activesupport (= 7.0.4.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4.2)
activesupport (= 7.0.4.2)
globalid (>= 0.3.6)
activemodel (7.0.4.2)
activesupport (= 7.0.4.2)
activerecord (7.0.4.2)
activemodel (= 7.0.4.2)
activesupport (= 7.0.4.2)
activestorage (7.0.4.2)
actionpack (= 7.0.4.2)
activejob (= 7.0.4.2)
activerecord (= 7.0.4.2)
activesupport (= 7.0.4.2)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
Expand All @@ -43,11 +91,23 @@ GEM
aws-sigv4 (~> 1.1)
aws-sigv4 (1.6.0)
aws-eventstream (~> 1, >= 1.0.2)
blazer (3.0.1)
activerecord (>= 6.1)
chartkick (>= 5)
railties (>= 6.1)
safely_block (>= 0.4)
blazer-plus (0.1.0)
blazer
rails
builder (3.2.4)
chartkick (5.0.4)
concurrent-ruby (1.2.0)
crass (1.0.6)
date (3.3.4)
diff-lcs (1.5.0)
erubi (1.12.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
Expand All @@ -59,8 +119,24 @@ GEM
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.17.0)
net-imap (0.4.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.14.2-arm64-darwin)
racc (~> 1.4)
Expand All @@ -72,6 +148,20 @@ GEM
rack (2.2.6.2)
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4.2)
actioncable (= 7.0.4.2)
actionmailbox (= 7.0.4.2)
actionmailer (= 7.0.4.2)
actionpack (= 7.0.4.2)
actiontext (= 7.0.4.2)
actionview (= 7.0.4.2)
activejob (= 7.0.4.2)
activemodel (= 7.0.4.2)
activerecord (= 7.0.4.2)
activestorage (= 7.0.4.2)
activesupport (= 7.0.4.2)
bundler (>= 1.15.0)
railties (= 7.0.4.2)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
Expand Down Expand Up @@ -100,9 +190,14 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
safely_block (0.4.0)
thor (1.2.1)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.7)

PLATFORMS
Expand Down
40 changes: 0 additions & 40 deletions lib/sg_fargate_rails/blazer_queries_controller.rb

This file was deleted.

2 changes: 0 additions & 2 deletions lib/sg_fargate_rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module SgFargateRails
class Config
attr_reader :proxy_ip_addresses
attr_accessor :middleware_enabled
attr_accessor :blazer_extension_enabled

# NOTE: good_jobダッシュボードへのアクセスをproxy経由のアクセスに制限するかどうか
attr_accessor :restrict_access_to_good_job_dashboard
Expand All @@ -11,7 +10,6 @@ def initialize
self.proxy_ip_addresses = ENV['SG_PROXY_IP_ADDRESSES']
self.restrict_access_to_good_job_dashboard = Rails.env.production?
self.middleware_enabled = !Rails.env.development? && !Rails.env.test?
self.blazer_extension_enabled = defined?(Blazer)
end

def proxy_ip_addresses=(ip_addresses)
Expand Down
9 changes: 2 additions & 7 deletions lib/sg_fargate_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'sg_fargate_rails/maintenance'
require 'sg_fargate_rails/remote_ip'
require 'sg_fargate_rails/task_protection'
require 'sg_fargate_rails/blazer_queries_controller'

module SgFargateRails
class Railtie < ::Rails::Railtie
Expand All @@ -19,6 +18,8 @@ class Railtie < ::Rails::Railtie
app.config.middleware.insert_after SgFargateRails::RemoteIp, SgFargateRails::Maintenance
end

Blazer::Plus.blazer_danger_actionable_method ||= ->(blazer_user) { blazer_user.email.ends_with?('@sonicgarden.jp') }

ActiveSupport.on_load(:good_job_application_controller) do
before_action :sg_fargate_rails_proxy_access!, if: -> { SgFargateRails.config.restrict_access_to_good_job_dashboard }

Expand All @@ -28,12 +29,6 @@ def sg_fargate_rails_proxy_access!
end
end
end

Rails.application.reloader.to_prepare do
if SgFargateRails.config.blazer_extension_enabled
Blazer::QueriesController.prepend(SgFargateRails::BlazerQueriesController)
end
end
end
end
end
1 change: 1 addition & 0 deletions sg_fargate_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'lograge', '~> 0.12'
spec.add_dependency 'aws-sdk-ec2', '~> 1.413'
spec.add_dependency 'aws-sdk-scheduler', '~> 1.10'
spec.add_dependency 'blazer-plus'

spec.add_development_dependency 'rspec'
end

0 comments on commit c6c20e1

Please sign in to comment.