Commit f43727d
committed
Verify the SAMLResponse based on the raw query string
BREAKING CHANGE: The verify function now requires the *raw* query string from
the server in order to verify the signature.
Because `URI` parses and re-encodes URI-escapes in uppercase (`%3f` becomes
`%3F`, for instance), which leads to signature verification failures if the
other party uses lower case (or mixed case). This seems to have been an issue
with the current code base as well due to the various flags that need to be
supplied to the constructor to work around it.
The problem lies with the RFC 3986[^1] and the SAML specs[^2] that both offer
different implementations of the same thing. RFC 3986 states that say the URI
must be normalized so uppercasing %2f to %2F is correct behavior. The SAML
specs states that we must operate on the original URL-encoded values. Thus no
uppercasing is allowed. It is the author's opinion that Net::SAML2 should
follow the SAML spec and and that implementations that normalize the URI should
return the original URI to the application.
This code is mostly ported from Zaaksysteem's code base, written by MSTREEK.
Users of lighttpd need to be aware that they need to configure their instance
with the following http-parseopts:
server.http-parseopts = (
"url-normalize" => "disable",
"url-normalize-unreserved" => "disable",
"url-normalize-required" => "disable"
)
You cannot change it on a URI basis because lighttpd needs a parsed URI before
it can process conditions as was mentioned on #lighttpd:
> The request must be parsed (using server.http-parseopts settings) *before* you
> can apply lighttpd.conf conditions to the parsed results.
[^1]: https://www.rfc-editor.org/rfc/rfc3986#section-6.2.2.1
[^2]: https://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf
(line 620)
Signed-off-by: Wesley Schwengle <waterkip@cpan.org>1 parent 5fd7f45 commit f43727d
File tree
4 files changed
+45
-74
lines changed- lib/Net/SAML2/Binding
- t
4 files changed
+45
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 40 | | |
46 | 41 | | |
47 | 42 | | |
| |||
218 | 213 | | |
219 | 214 | | |
220 | 215 | | |
221 | | - | |
| 216 | + | |
222 | 217 | | |
223 | 218 | | |
224 | 219 | | |
| |||
235 | 230 | | |
236 | 231 | | |
237 | 232 | | |
238 | | - | |
239 | | - | |
240 | 233 | | |
241 | | - | |
242 | | - | |
243 | | - | |
| 234 | + | |
| 235 | + | |
244 | 236 | | |
245 | 237 | | |
246 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
247 | 241 | | |
248 | 242 | | |
249 | | - | |
| 243 | + | |
250 | 244 | | |
251 | 245 | | |
252 | | - | |
| 246 | + | |
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
256 | 250 | | |
257 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
258 | 257 | | |
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
262 | | - | |
263 | 261 | | |
264 | | - | |
265 | | - | |
| 262 | + | |
| 263 | + | |
266 | 264 | | |
267 | | - | |
268 | | - | |
269 | | - | |
| 265 | + | |
270 | 266 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 267 | + | |
283 | 268 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 269 | + | |
| 270 | + | |
295 | 271 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
302 | 275 | | |
| 276 | + | |
303 | 277 | | |
304 | | - | |
305 | | - | |
306 | | - | |
| 278 | + | |
307 | 279 | | |
308 | 280 | | |
309 | | - | |
| 281 | + | |
310 | 282 | | |
311 | 283 | | |
312 | 284 | | |
313 | 285 | | |
314 | | - | |
315 | | - | |
| 286 | + | |
316 | 287 | | |
317 | 288 | | |
318 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | | - | |
| 21 | + | |
| 22 | + | |
24 | 23 | | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
0 commit comments