Skip to content

Commit d588009

Browse files
Remove session binding to the CSRF token, as it is unnecessary for serverless services on the backend.
1 parent cd3d62a commit d588009

File tree

3 files changed

+0
-47
lines changed

3 files changed

+0
-47
lines changed

dotnet/src/dotnetcore/GxNetCoreStartup/CsrfHelper.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,4 @@ internal static void SetAntiForgeryTokens(IAntiforgery _antiforgery, HttpContext
6262
}
6363

6464
}
65-
public class SessionIdAntiforgeryAdditionalDataProvider : IAntiforgeryAdditionalDataProvider
66-
{
67-
static readonly ILog log = log4net.LogManager.GetLogger(typeof(SessionIdAntiforgeryAdditionalDataProvider));
68-
public string GetAdditionalData(HttpContext context)
69-
{
70-
context.NewSessionCheck();
71-
GXLogging.Debug(log, $"Setting session id as additional CSRF token data:", context.Session.Id);
72-
return context.Session.Id.Trim();
73-
}
74-
75-
public bool ValidateAdditionalData(HttpContext context, string additionalData)
76-
{
77-
if (context.IsNewSession())
78-
{
79-
return true;
80-
}
81-
else
82-
{
83-
bool validSession = context.Session.Id.Trim().CompareTo(additionalData.Trim()) == 0 ? true : false;
84-
GXLogging.Warn(log, $"Session id in CSRF token ({additionalData}) does not match the current session id ({context.Session.Id})");
85-
return validSession;
86-
}
87-
}
88-
}
89-
9065
}

dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public void ConfigureServices(IServiceCollection services)
253253
options.HeaderName = HttpHeader.X_CSRF_TOKEN_HEADER;
254254
options.SuppressXFrameOptionsHeader = false;
255255
});
256-
services.AddSingleton<IAntiforgeryAdditionalDataProvider, SessionIdAntiforgeryAdditionalDataProvider>();
257256
}
258257
services.AddDirectoryBrowser();
259258
if (GXUtil.CompressResponse())

dotnet/src/dotnetframework/GxClasses/Helpers/CsrfHelper.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
using System.Web.Helpers;
55
using GeneXus.Application;
66
using GeneXus.Utils;
7-
using log4net;
87

98
namespace GeneXus.Http
109
{
1110
internal class CSRFHelper
1211
{
13-
//AntiForgeryConfig.AdditionalDataProvider = new SessionIdAntiforgeryAdditionalDataProvider();
14-
1512
[SecuritySafeCritical]
1613
internal static void ValidateAntiforgery(HttpContext context)
1714
{
@@ -53,22 +50,4 @@ static void ValidateAntiforgeryImpl(HttpContext context)
5350
}
5451
}
5552
}
56-
57-
58-
public class SessionIdAntiforgeryAdditionalDataProvider : IAntiForgeryAdditionalDataProvider
59-
{
60-
static readonly ILog log = log4net.LogManager.GetLogger(typeof(SessionIdAntiforgeryAdditionalDataProvider));
61-
public string GetAdditionalData(HttpContextBase context)
62-
{
63-
GXLogging.Debug(log, $"Setting session id as additional CSRF token data:", context.Session.SessionID);
64-
return context.Session.SessionID.Trim();
65-
}
66-
[SecuritySafeCritical]
67-
public bool ValidateAdditionalData(HttpContextBase context, string additionalData)
68-
{
69-
bool validSession = context.Session.SessionID.Trim().CompareTo(additionalData.Trim()) == 0 ? true : false;
70-
GXLogging.Warn(log, $"Session id in CSRF token ({additionalData}) does not match the current session id ({context.Session.SessionID})");
71-
return validSession;
72-
}
73-
}
7453
}

0 commit comments

Comments
 (0)