Skip to content

Commit

Permalink
Merge pull request #292 from aleksei-burlakov/enable-rails-8.0
Browse files Browse the repository at this point in the history
Dev: enable rails-8.0
  • Loading branch information
aleksei-burlakov authored Nov 28, 2024
2 parents c5ff432 + 2ae19bf commit 1d325f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions hawk/app/lib/hawk/secure_cookies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ def call(env)
if headers['Set-Cookie'].present?
cookies = headers['Set-Cookie'].split(COOKIE_SEPARATOR)

# cookies might be 2-D array in the rack-3 / sprockets-4.2
cookies.each do |cookie|
next if cookie.blank?
next if cookie =~ /;\s*secure/i

cookie << '; Secure ; HttpOnly'
# no matter what, always add Secure + HttpOnly
if not cookie.kind_of?(Array)
cookie << '; Secure ; HttpOnly'
else
cookie.each do |cookie_atom|
next if cookie_atom.blank?
cookie_atom << '; Secure ; HttpOnly'
end
end
end

headers['Set-Cookie'] = cookies.join(COOKIE_SEPARATOR)
Expand Down
8 changes: 7 additions & 1 deletion hawk/config/initializers/secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you"ll be exposed to dictionary attacks.
Rails.application.secrets.secret_key_base = secret_file.open(
key_base = secret_file.open(
File::RDWR | File::CREAT,
0600
) do |f|
Expand All @@ -29,4 +29,10 @@

secret
end
if Gem.loaded_specs['rails'].version >= Gem::Version.new("7.2")
Rails.application.credentials.secret_key_base = key_base
else
# deprecated
Rails.application.secrets.secret_key_base = key_base
end
end
2 changes: 1 addition & 1 deletion hawk/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
get '/sim/intervals/:id', as: :sim_intervals, to: 'simulator#intervals', defaults: { format: 'json' }, constraints: {id: regex_safe_id }
get '/sim/help', as: :sim_help, to: 'simulator#help'

resource :dashboard, only: [:show, :add, :remove] do
resource :dashboard, only: [:show] do
member do
get :add
post :add
Expand Down

0 comments on commit 1d325f4

Please sign in to comment.