File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ The following configuration keys are supported:
121121
122122 - ` :anti-forgery ` -
123123 Set to true to add CSRF protection via the [ ring-anti-forgery] [ 5 ]
124- library.
124+ library, or supply a map of options to be passed to the middleware .
125125
126126 - ` :content-type-options ` -
127127 Prevents attacks based around media-type confusion. See:
Original file line number Diff line number Diff line change 4747 :session {:flash true
4848 :cookie-attrs {:http-only true }
4949 :store default-session-store }
50- :security {:anti-forgery true
50+ :security {:anti-forgery { :safe-header " X-Ring-Anti-Forgery " }
5151 :frame-options :sameorigin
5252 :content-type-options :nosniff }
5353 :static {:resources " public" }
Original file line number Diff line number Diff line change 241241 (assoc-in [:security :xss-protection :mode ] :block ))))
242242 resp (handler (request :get " /" ))]
243243 (is (not (nil? (get-in resp [:headers " X-XSS-Protection" ]))))
244- (is (= (get-in resp [:headers " X-XSS-Protection" ]) " 1; mode=block" )))))
244+ (is (= (get-in resp [:headers " X-XSS-Protection" ]) " 1; mode=block" ))))
245+
246+ (testing " anti-forgery"
247+ (let [handler (-> (constantly (response " foo" ))
248+ (wrap-defaults site-defaults))]
249+ (is (= 403 (:status (handler (request :post " /" )))))
250+ (is (= 200 (:status (handler (-> (request :post " /" )
251+ (header " X-Ring-Anti-Forgery" " 1" )))))))))
You can’t perform that action at this time.
0 commit comments