@@ -20,17 +20,26 @@ def self.root
2020
2121 def self . app ( flipper = nil , options = { } )
2222 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+ { }
2827 end
2928
3029 app = -> ( _ ) { [ 200 , { Rack ::CONTENT_TYPE => 'text/html' } , [ '' ] ] }
3130 builder = Rack ::Builder . new
3231 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+
3443 builder . use Rack ::MethodOverride
3544 builder . use Flipper ::Middleware ::SetupEnv , flipper , env_key : env_key
3645 builder . use Flipper ::UI ::Middleware , flipper : flipper , env_key : env_key
0 commit comments