@@ -20,17 +20,26 @@ def self.root
20
20
21
21
def self . app ( flipper = nil , options = { } )
22
22
env_key = options . fetch ( :env_key , 'flipper' )
23
-
24
- if options . key? ( :rack_protection )
25
- warn "[DEPRECATION] `rack_protection` option is deprecated. " +
26
- "Flipper::UI now only includes Rack::Protection::AuthenticityToken middleware. " +
27
- "If you need additional protection, you can add it yourself."
23
+ rack_protection_options = if options . key? ( :rack_protection )
24
+ options [ :rack_protection ]
25
+ else
26
+ { }
28
27
end
29
28
30
29
app = -> ( _ ) { [ 200 , { Rack ::CONTENT_TYPE => 'text/html' } , [ '' ] ] }
31
30
builder = Rack ::Builder . new
32
31
yield builder if block_given?
33
- builder . use Rack ::Protection ::AuthenticityToken
32
+
33
+ # Only use Rack::Protection::AuthenticityToken if no other options are
34
+ # provided. Should avoid some pain for some people. If any options are
35
+ # provided then go whole hog and include all of Rack::Protection for
36
+ # backwards compatibility.
37
+ if rack_protection_options . empty?
38
+ builder . use Rack ::Protection ::AuthenticityToken
39
+ else
40
+ builder . use Rack ::Protection , rack_protection_options
41
+ end
42
+
34
43
builder . use Rack ::MethodOverride
35
44
builder . use Flipper ::Middleware ::SetupEnv , flipper , env_key : env_key
36
45
builder . use Flipper ::UI ::Middleware , flipper : flipper , env_key : env_key
0 commit comments