Skip to content

Conversation

@markekraus
Copy link
Contributor

@markekraus markekraus commented May 3, 2018

PR Summary

This PR switches the logic of when the Web Cmdlets handle redirects when the Authorization header is present. .NET Core 2.1 no longer sends the Authorization header by default (dotnet/corefx#26864). however, we introduced the ability to do so leveraging the previous default behavior through the use of the -PreserveAuthorizationOnRedirect switch.

This PR also corrects a bug introduced 6.0.0 where certain redirect types redirect from POST to GET were set which should have passed through POST to POST and some were improperly passing through POST to POST which should have been doing POST to GET. This correction is a breaking change. It was made apparent as now the redirection behavior is being managed by CoreFX which is doing the correct behavior, test were added for both when CoreFX and the Web Cmdlets manage redirection.

PR Checklist

@markekraus markekraus added the Breaking-Change breaking change that may affect users label May 3, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented May 3, 2018

I restarted CI Travis MacOs - it seems temporary failed.

@markekraus markekraus changed the title WIP: Fix Web Cmdlets for .NET Core 2.1 Fix Web Cmdlets for .NET Core 2.1 May 3, 2018
@markekraus
Copy link
Contributor Author

@TravisEz13 can you ping someone to review? I'd definitely like this to be merged before the next preview or RC since without it, there are effectively known regressions in master.

@TravisEz13
Copy link
Member

@iSazonov Could you review this change?

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using (client = GetHttpClient(false))
using (HttpRequestMessage redirectRequest = GetRequest(currentUri, stripAuthorization:true))
// Continue to handle redirection
using (client = GetHttpClient(true))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we use named parameter GetHttpClient(handleRedirect:true) - it is more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not "usually". there are plenty of examples where the pattern is not used. It's also not listed in the guidance. Please add it to the guidance if you expect it in submissions. I will change it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have so many patterns that it is impossible to document them all. So we have activated CodeFactor and will do fine tuning. We should then update our guidances.

@markekraus
Copy link
Contributor Author

@iSazonov I have #5610 for tracking refactoring the Web Cmdlets. There is much work to be done there.. but every time I try, the PRs are a nightmare. I'm pretty discourage from wasting my time on it further until I can get clear answers on the way to move forward.

@TravisEz13
Copy link
Member

Note: there are CodeFactor issues. We should try to fix these error in the new and changed code. This was added after you started this PR so I think we can defer this.

@TravisEz13 TravisEz13 merged commit 525f593 into PowerShell:master May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adjust logic of Web Cmdlet Authorization Header Stripping to work with .NET Core 2.1

4 participants