Skip to content

Commit

Permalink
update host authz to exclude health checks
Browse files Browse the repository at this point in the history
- host header is not sent by e.g. AWS ELB when performing a health check
- also removes domain routing constraints from health checks
  • Loading branch information
ezekg committed Aug 4, 2023
1 parent d209271 commit ac616fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.host_authorization = { exclude: -> req { req.path =~ %r(^/v\d+/health) } }
config.hosts.concat(
[ENV.fetch('KEYGEN_HOST'), *ENV.fetch('KEYGEN_HOSTS', '').split(',')].then { |host|
host.uniq.compact_blank.map { _1.downcase.strip }
Expand Down
12 changes: 6 additions & 6 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@

scope module: :api do
namespace :v1 do
# Health checks
scope :health do
get '/', to: 'health#general_health'
get :webhooks, to: 'health#webhook_health'
end

constraints **domain_constraints, **subdomain_constraints do
if Keygen.multiplayer?
post :stripe, to: 'stripe#receive_webhook'
Expand All @@ -443,12 +449,6 @@
end
end

# Health checks
scope :health do
get '/', to: 'health#general_health'
get :webhooks, to: 'health#webhook_health'
end

# Recover
scope constraints: MimeTypeConstraint.new(:jsonapi, :json, raise_on_no_match: true), defaults: { format: :jsonapi } do
post :recover, to: 'recoveries#recover'
Expand Down

0 comments on commit ac616fa

Please sign in to comment.