Skip to content

Commit

Permalink
CORS web security patch fix on doubtfire-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Epitacio Neto committed Dec 28, 2024
1 parent 293b692 commit e22976c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,21 @@ class Application < Rails::Application
Rails.root.join('app', 'models', 'similarity')

# CORS config
config.middleware.insert_before Warden::Manager, Rack::Cors do
# config.middleware.insert_before Warden::Manager, Rack::Cors do
# allow do
# origins '*'
# resource '*', headers: :any, methods: %i(get post put delete options)
# end
# end

# Updated CORS Security Patch Fix
config.middleware.insert_before Warden::Manager, Rack::Cors do
allow do
origins '*'
origins ENV['DF_ALLOWED_ORIGINS'].split(',')
resource '*', headers: :any, methods: %i(get post put delete options)
end
end
end

# Generators for test framework
if Rails.env.test?
config.generators do |g|
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ services:
environment:
RAILS_ENV: 'development'

# CORS Vulnerability Remediation
# The DF_ALLOWED_ORIGINS variable must reflect the exact URLs where the OnTrack app will be accessed (e.g., production, staging, or development URLs).
# Allowed origins must reflect the exact URLs where the OnTrack app will be accessed.
# Failure to update this variable with the correct origins will cause inaccessibility.
DF_ALLOWED_ORIGINS: "http://localhost:4200"

DF_STUDENT_WORK_DIR: /student-work
DF_INSTITUTION_HOST: http://localhost:3000
DF_INSTITUTION_PRODUCT_NAME: OnTrack
Expand Down

0 comments on commit e22976c

Please sign in to comment.