Browse Source
Merge pull request #20819 from abpframework/Session-IpAddresses
Truncate `IpAddresses` of `IdentitySession`.
pull/20948/head
liangshiwei
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
17 additions and
2 deletions
-
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentitySessionConsts.cs
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentitySession.cs
|
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
@ -80,7 +80,22 @@ public class IdentitySession : BasicAggregateRoot<Guid>, IMultiTenant |
|
|
|
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) |
|
|
|
|