Skip to content

Commit

Permalink
Use SameSite=strict for orangelight cookie
Browse files Browse the repository at this point in the history
This reduces the number of scenarios in which the cookie will
be sent, providing better CSRF protection and reducing the
size of the Cookies header in some cases.
  • Loading branch information
sandbergja committed Jan 10, 2024
1 parent b055c70 commit 4e72bea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/initializers/cookies_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.action_dispatch.cookies_serializer = :json
Rails.application.config.action_dispatch.cookies_same_site_protection = :strict
16 changes: 16 additions & 0 deletions spec/requests/cookies_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Cookies' do
it 'sets SameSite=strict' do
get '/'
expect(response.headers['Set-Cookie']).to include('SameSite=Strict')
end
it 'sets HttpOnly' do
get '/'
expect(response.headers['Set-Cookie']).to include('HttpOnly')
end
it 'sets Secure' do
get '/'
expect(response.headers['Set-Cookie']).to include('HttpOnly')
end
end

0 comments on commit 4e72bea

Please sign in to comment.