Skip to content

Commit 9c14764

Browse files
authored
Remove Rack::Protection::EncryptedCookie (#1989)
The rack-session gem has equivalent functionality. Close #1945
1 parent 667056c commit 9c14764

File tree

14 files changed

+37
-974
lines changed

14 files changed

+37
-974
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ permissions:
1111

1212
jobs:
1313
rack-protection:
14-
name: rack-protection (${{ matrix.ruby }}, rack ${{ matrix.rack }}, rack-session ${{ matrix.rack_session }})
14+
name: rack-protection (${{ matrix.ruby }}, rack ${{ matrix.rack }})
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 5
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
rack:
2121
- stable
22-
rack_session:
23-
- stable
2422
ruby:
2523
- "2.6"
2624
- "2.7"
@@ -32,10 +30,9 @@ jobs:
3230
- "truffleruby"
3331
include:
3432
# Rack
35-
- { ruby: 3.2, rack: head, rack_session: stable }
36-
- { ruby: 3.2, rack: stable, rack_session: head }
37-
# https://github.com/sinatra/sinatra/issues/1988
38-
- { ruby: ruby-head, rack: stable, rack_session: stable, allow-failure: true }
33+
- { ruby: 3.2, rack: head }
34+
# Never fail our build due to problems with head
35+
- { ruby: ruby-head, rack: stable, allow-failure: true }
3936
env:
4037
rack: ${{ matrix.rack }}
4138
steps:
@@ -65,7 +62,7 @@ jobs:
6562
github-token: ${{ secrets.GITHUB_TOKEN }}
6663
webhook: ${{ secrets.DISCORD_WEBHOOK }}
6764
sinatra:
68-
name: ${{ matrix.ruby }} (Rack ${{ matrix.rack }}, Puma ${{ matrix.puma }}, Tilt ${{ matrix.tilt }})
65+
name: ${{ matrix.ruby }} (Rack ${{ matrix.rack }}, Rack::Session ${{ matrix.rack_session }}, Puma ${{ matrix.puma }}, Tilt ${{ matrix.tilt }})
6966
runs-on: ubuntu-latest
7067
timeout-minutes: 15
7168
strategy:
@@ -75,23 +72,28 @@ jobs:
7572
- stable
7673
rack:
7774
- stable
75+
rack_session:
76+
- stable
7877
tilt:
7978
- stable
8079
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
8180
ruby: [2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby, truffleruby]
8281
include:
8382
# Rack
84-
- { ruby: 3.2, rack: head, puma: stable, tilt: stable, allow-failure: true }
83+
- { ruby: 3.2, rack: head, puma: stable, tilt: stable, rack_session: stable, allow-failure: true }
84+
# Rack::Session
85+
- { ruby: 3.2, rack: stable, puma: stable, tilt: stable, rack_session: head, allow-failure: true }
8586
# Puma
86-
- { ruby: 3.2, rack: stable, puma: head, tilt: stable, allow-failure: true }
87+
- { ruby: 3.2, rack: stable, puma: head, tilt: stable, rack_session: stable, allow-failure: true }
8788
# Tilt
88-
- { ruby: 3.2, rack: stable, puma: stable, tilt: head, allow-failure: true }
89+
- { ruby: 3.2, rack: stable, puma: stable, tilt: head, rack_session: stable, allow-failure: true }
8990
# Never fail our build due to problems with head
90-
- { ruby: ruby-head, rack: stable, puma: stable, tilt: stable, allow-failure: true }
91-
- { ruby: jruby-head, rack: stable, puma: stable, tilt: stable, allow-failure: true }
92-
- { ruby: truffleruby-head, rack: stable, puma: stable, tilt: stable, allow-failure: true }
91+
- { ruby: ruby-head, rack: stable, puma: stable, tilt: stable, rack_session: stable, allow-failure: true }
92+
- { ruby: jruby-head, rack: stable, puma: stable, tilt: stable, rack_session: stable, allow-failure: true }
93+
- { ruby: truffleruby-head, rack: stable, puma: stable, tilt: stable, rack_session: stable, allow-failure: true }
9394
env:
9495
rack: ${{ matrix.rack }}
96+
rack_session: ${{ matrix.rack_session }}
9597
puma: ${{ matrix.puma }}
9698
tilt: ${{ matrix.tilt }}
9799

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ rack_version = ENV['rack'].to_s
99
rack_version = nil if rack_version.empty? || (rack_version == 'stable')
1010
rack_version = { github: 'rack/rack' } if rack_version == 'head'
1111
gem 'rack', rack_version
12+
13+
rack_session_version = ENV['rack_session'].to_s
14+
rack_session_version = nil if rack_session_version.empty? || (rack_session_version == 'stable')
15+
rack_session_version = { github: 'rack/rack-session' } if rack_session_version == 'head'
16+
gem 'rack-session', rack_session_version
17+
1218
gem 'rackup'
1319

1420
puma_version = ENV['puma'].to_s

lib/sinatra/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
end
99
require 'tilt'
1010
require 'rack/protection'
11+
require 'rack/session'
1112
require 'mustermann'
1213
require 'mustermann/sinatra'
1314
require 'mustermann/regular'
@@ -1929,7 +1930,7 @@ def force_encoding(*args)
19291930
set :dump_errors, proc { !test? }
19301931
set :show_exceptions, proc { development? }
19311932
set :sessions, false
1932-
set :session_store, Rack::Protection::EncryptedCookie
1933+
set :session_store, Rack::Session::Cookie
19331934
set :logging, false
19341935
set :protection, true
19351936
set :method_override, false

rack-protection/Gemfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,3 @@ rack_version = ENV['rack'].to_s
1111
rack_version = nil if rack_version.empty? || (rack_version == 'stable')
1212
rack_version = { github: 'rack/rack' } if rack_version == 'head'
1313
gem 'rack', rack_version
14-
15-
rack_session_version = ENV['rack_session'].to_s
16-
rack_session_version = nil if rack_session_version.empty? || (rack_session_version == 'stable')
17-
rack_session_version = { github: 'rack/rack-session' } if rack_session_version == 'head'
18-
gem 'rack-session', rack_session_version

rack-protection/lib/rack/protection.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
require 'rack/protection/version'
44
require 'rack'
5-
require 'rack/session'
65

76
module Rack
87
module Protection
98
autoload :AuthenticityToken, 'rack/protection/authenticity_token'
109
autoload :Base, 'rack/protection/base'
1110
autoload :CookieTossing, 'rack/protection/cookie_tossing'
1211
autoload :ContentSecurityPolicy, 'rack/protection/content_security_policy'
13-
autoload :Encryptor, 'rack/protection/encryptor'
14-
autoload :EncryptedCookie, 'rack/protection/encrypted_cookie'
1512
autoload :EscapedParams, 'rack/protection/escaped_params'
1613
autoload :FormToken, 'rack/protection/form_token'
1714
autoload :FrameOptions, 'rack/protection/frame_options'

rack-protection/lib/rack/protection/authenticity_token.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Protection
5151
# Here is <tt>server.rb</tt>:
5252
#
5353
# require 'rack/protection'
54+
# require 'rack/session'
5455
#
5556
# app = Rack::Builder.app do
5657
# use Rack::Session::Cookie, secret: 'secret'

0 commit comments

Comments
 (0)