|
106 | 106 | (response/status 401)))))
|
107 | 107 |
|
108 | 108 | (defn wrap-html-defaults
|
109 |
| - "Middleware that applies a customized set of Ring defaults for HTML routes. |
110 |
| -
|
111 |
| - This middleware configures a subset of Ring's `site-defaults` that's |
112 |
| - appropriate for server-rendered HTML pages. |
113 |
| -
|
114 |
| - Applied configurations: |
115 |
| - - Parameters: Parses standard, nested, and keyword parameters |
116 |
| - - Static resources: Enabled |
117 |
| - - Security headers: |
118 |
| - - X-Frame-Options |
119 |
| - - X-Content-Type-Options |
120 |
| - - X-XSS-Protection |
121 |
| - - X-Permitted-Cross-Domain-Policies |
122 |
| - - X-Download-Options |
123 |
| - - Cookie response attributes |
124 |
| -
|
125 |
| - Explicitly disabled: |
126 |
| - - Session handling: Disabled completely as we use stateless JWT auth |
127 |
| - - Global anti-forgery: Disabled here but applied selectively to form-handling |
128 |
| - routes, see `anti-forgery` |
129 |
| -
|
130 |
| - Usage: Apply this middleware to routes that serve HTML content, and separately |
131 |
| - apply `anti-forgery` middleware only to routes that process form submissions." |
| 109 | + "Middleware that applies a set of Ring defaults for HTML routes. |
| 110 | + Among other things, this middleware enables: |
| 111 | +
|
| 112 | + - Anti-forgery protection |
| 113 | + - Sessions (necessary for CSRF tokens to work) |
| 114 | +
|
| 115 | + We disable wrapping static resources here because these resources need to be |
| 116 | + available for all routes, and this middleware is set for certain routes only. |
| 117 | + FIXME: This might be troublesome, review middleware order. |
| 118 | +
|
| 119 | + And other defaults that are not immediately relevant to us. See |
| 120 | + `site-defaults` for the full details." |
132 | 121 | [handler]
|
133 | 122 | (wrap-defaults
|
134 | 123 | handler
|
135 | 124 | (-> site-defaults
|
136 |
| - (assoc :session false) |
137 |
| - (assoc :security |
138 |
| - (-> (:security site-defaults) |
139 |
| - (assoc :anti-forgery false)))))) |
| 125 | + (assoc :static false)))) |
140 | 126 |
|
141 | 127 | ;; TODO: Investigate whether Content Security Policy is needed:
|
142 | 128 | ;; - https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
|
|
206 | 192 | (def anti-forgery
|
207 | 193 | "Anti-forgery middleware for HTML forms, see docs on `wrap-anti-forgery`"
|
208 | 194 | wrap-anti-forgery)
|
209 |
| - |
210 |
| -;; File upload handling is commented out for now |
211 |
| -;; To enable file uploads, uncomment the following: |
212 |
| -;; (defn wrap-multipart-params |
213 |
| -;; "Handle multipart form data including file uploads" |
214 |
| -;; [handler] |
215 |
| -;; (-> handler |
216 |
| -;; (multipart-params/wrap-multipart-params))) |
0 commit comments