Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: enable rails-8.0 #292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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