Commit c831849
Add check for unset correlation ID when configuring request headers (#2435)
If a correlation ID hasn't been configured for a request, the 'UNSET'
value will be sent to the server, and the server will then return that
'UNSET' value from the response. To prevent this, the correlation ID
should only be appended if it is a valid value.
Additionally, tests have been added to ensure that an 'UNSET' value
isn't added to the request headers, and valid correlation IDs are being
added to the request headers on a valid request.
Also, there are a few tweaks made to `NativeAuthRequestHandlerTest` -
there are some tests where a request is configured and created, but
there are no assertions made on those requests. I've added a few checks
to tests that were missing validations, and some other small tweaks.
Update:
“If a correlation ID hasn't been configured for a request, the 'UNSET'
value will be sent to the server, and the server will then return that
'UNSET' value from the response.” -> After experiment, this assumption
is wrong. The header used on the SDK side is client-request-id not
ms-client-request-id, these two values are different if they both
attached in the response header. The interesting thing is that, if
client sends invalid correlation id like "UNSET", the server would not
return the client-request-id to the client. On the contrary, if the
correlation id is valid and client sent it in the client-request-id
header, the server will return it as the same value in the
client-request-id header. SDK made the assumption that if no
client-request-id header is sent to the server from client, the server
will generate one for the client seems untrue. The correlation id is
dependant on client-request-id x-ms-request-id is the request specific,
it targets the Service Request Id not the CorrelationId, while
x-ms-request-id is returned from the server in all times.
---------
Co-authored-by: yuxin <yuxin@microsoft.com>1 parent 44d9252 commit c831849
4 files changed
Lines changed: 265 additions & 20 deletions
File tree
- common4j/src
- main/com/microsoft/identity/common/java
- logging
- nativeauth/providers
- test/com/microsoft/identity/common/java/nativeauth/providers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
80 | | - | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
312 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
| |||
0 commit comments