Skip to content

Commit

Permalink
Merge pull request #20819 from abpframework/Session-IpAddresses
Browse files Browse the repository at this point in the history
Truncate `IpAddresses` of `IdentitySession`.
  • Loading branch information
realLiangshiwei authored Oct 2, 2024
2 parents cdcec59 + 05fd7be commit 0386df3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class IdentitySessionConsts

public static int MaxClientIdLength { get; set; } = 64;

public static int MaxIpAddressesLength { get; set; } = 256;
public static int MaxIpAddressesLength { get; set; } = 2048;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,22 @@ public IEnumerable<string> GetIpAddresses()
private static string JoinAsString(IEnumerable<string> list)
{
var serialized = string.Join(",", list);
return serialized.IsNullOrWhiteSpace() ? null : serialized;
if (serialized.IsNullOrWhiteSpace())
{
return null;
}

while (serialized.Length > IdentitySessionConsts.MaxIpAddressesLength)
{
var lastCommaIndex = serialized.IndexOf(',');
if (lastCommaIndex < 0)
{
return serialized;
}
serialized = serialized.Substring(lastCommaIndex + 1);
}

return serialized;
}

private string[] GetArrayFromString(string str)
Expand Down

0 comments on commit 0386df3

Please sign in to comment.