Skip to content

Commit cd3d62a

Browse files
New sessions must not validate session data bound to CSRF token.
1 parent d4886c3 commit cd3d62a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dotnet/src/dotnetcore/GxNetCoreStartup/CsrfHelper.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@ public string GetAdditionalData(HttpContext context)
7474

7575
public bool ValidateAdditionalData(HttpContext context, string additionalData)
7676
{
77-
bool validSession = context.Session.Id.Trim().CompareTo(additionalData.Trim()) == 0 ? true : false;
78-
GXLogging.Warn(log, $"Session id in CSRF token ({additionalData}) does not match the current session id ({context.Session.Id})");
79-
return validSession;
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+
}
8087
}
8188
}
8289

0 commit comments

Comments
 (0)