Skip to content

Commit a64d373

Browse files
fix: Prevent Authentication header from being passed during cross-origin redirects (box/box-codegen#648) (#382)
1 parent 2df3d8f commit a64d373

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "ead925a", "specHash": "091b558", "version": "1.6.0" }
1+
{ "engineHash": "b5ed925", "specHash": "091b558", "version": "1.6.0" }

Box.Sdk.Gen/Networking/BoxNetworkClient/BoxNetworkClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ async Task<FetchResponse> INetworkClient.FetchAsync(FetchOptions options)
105105
throw new BoxSdkException($"Redirect response missing Location header for: {options.Url}");
106106
}
107107

108+
var originUri = new Uri(url);
109+
var redirectUri = new Uri(locationHeader.Value.First());
110+
var sameOrigin = originUri.Host == redirectUri.Host && originUri.Port == redirectUri.Port && originUri.Scheme == redirectUri.Scheme;
108111
return await ((INetworkClient)this).FetchAsync(new FetchOptions(locationHeader.Value.First(), "GET", options.ContentType, options.ResponseFormat)
109-
{ Auth = options.Auth, NetworkSession = networkSession }).ConfigureAwait(false);
112+
{ Auth = sameOrigin ? options.Auth : null, NetworkSession = networkSession }).ConfigureAwait(false);
110113
}
111114

112115
if (statusCode == 401)

0 commit comments

Comments
 (0)