Commit 12e910fe authored by justcoding121's avatar justcoding121 Committed by justcoding121

Fix WinAuth issue when request body is not read

parent ace7c729
...@@ -116,8 +116,7 @@ namespace Titanium.Web.Proxy.Examples.Basic ...@@ -116,8 +116,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
//read request headers //read request headers
var requestHeaders = e.WebSession.Request.RequestHeaders; var requestHeaders = e.WebSession.Request.RequestHeaders;
var method = e.WebSession.Request.Method.ToUpper(); if (e.WebSession.Request.HasBody)
if (method == "POST" || method == "PUT" || method == "PATCH")
{ {
//Get/Set request body bytes //Get/Set request body bytes
byte[] bodyBytes = await e.GetRequestBody(); byte[] bodyBytes = await e.GetRequestBody();
......
...@@ -26,6 +26,11 @@ namespace Titanium.Web.Proxy.Http ...@@ -26,6 +26,11 @@ namespace Titanium.Web.Proxy.Http
/// </summary> /// </summary>
public Version HttpVersion { get; set; } public Version HttpVersion { get; set; }
/// <summary>
/// Has request body?
/// </summary>
public bool HasBody => Method == "POST" || Method == "PUT" || Method == "PATCH";
/// <summary> /// <summary>
/// Request Http hostanem /// Request Http hostanem
/// </summary> /// </summary>
......
...@@ -322,6 +322,16 @@ namespace Titanium.Web.Proxy ...@@ -322,6 +322,16 @@ namespace Titanium.Web.Proxy
PrepareRequestHeaders(args.WebSession.Request.RequestHeaders, args.WebSession); PrepareRequestHeaders(args.WebSession.Request.RequestHeaders, args.WebSession);
args.WebSession.Request.Host = args.WebSession.Request.RequestUri.Authority; args.WebSession.Request.Host = args.WebSession.Request.RequestUri.Authority;
//if win auth is enabled
//we need a cache of request body
//so that we can send it after authentication in WinAuthHandler.cs
if (EnableWinAuth
&& !RunTime.IsRunningOnMono()
&& args.WebSession.Request.HasBody)
{
await args.GetRequestBody();
}
//If user requested interception do it //If user requested interception do it
if (BeforeRequest != null) if (BeforeRequest != null)
{ {
......
...@@ -96,7 +96,8 @@ namespace Titanium.Web.Proxy ...@@ -96,7 +96,8 @@ namespace Titanium.Web.Proxy
//challenge value will start with any of the scheme selected //challenge value will start with any of the scheme selected
else else
{ {
scheme = authSchemes.FirstOrDefault(x => authHeader.Value.StartsWith(x, StringComparison.OrdinalIgnoreCase)); scheme = authSchemes.FirstOrDefault(x => authHeader.Value.StartsWith(x, StringComparison.OrdinalIgnoreCase)
&& authHeader.Value.Length > x.Length + 1);
var serverToken = authHeader.Value.Substring(scheme.Length + 1); var serverToken = authHeader.Value.Substring(scheme.Length + 1);
var clientToken = WinAuthHandler.GetFinalAuthToken(args.WebSession.Request.Host, serverToken, args.Id); var clientToken = WinAuthHandler.GetFinalAuthToken(args.WebSession.Request.Host, serverToken, args.Id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment