Skip to content

Commit 4d7a01c

Browse files
Adjusted the maximum token size dynamically based on the token length to prevent 403 Forbidden errors when handling large tokens. (#971)
(cherry picked from commit 07e1dae)
1 parent 93a7266 commit 4d7a01c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

dotnet/src/dotnetframework/GxClasses/Security/WebSecurity.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ internal static WebSecureToken getWebSecureToken(string signedToken, string secr
128128
using (var hmac = new System.Security.Cryptography.HMACSHA256(bSecretKey))
129129
{
130130
var handler = new JwtSecurityTokenHandler();
131+
if (signedToken.Length >= handler.MaximumTokenSizeInBytes)
132+
{
133+
handler.MaximumTokenSizeInBytes = signedToken.Length + 1;
134+
}
131135
var validationParameters = new TokenValidationParameters
132136
{
133137
ClockSkew = TimeSpan.FromMinutes(1),

0 commit comments

Comments
 (0)