From b5848b96e7c76782c86145fa9adc9050b13e20b0 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 17 Oct 2026 17:15:07 +0330 Subject: [PATCH] last ... --- Dtos/XOpenActionDto.cs | 2 ++ Extensions/xIdentityModelsExtensions.cs | 45 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/Dtos/XOpenActionDto.cs b/Dtos/XOpenActionDto.cs index 5f01cfd..2064cb0 100644 --- a/Dtos/XOpenActionDto.cs +++ b/Dtos/XOpenActionDto.cs @@ -11,6 +11,8 @@ namespace xIdentityModels.Dtos public struct XOpenActions { public const string HandShake = "HandShake"; + public const string GetApiKey = "GetApiKey"; + public const string UseApiKey = "UseApiKey"; public const string GetUserInfo = "GetUserInfo"; public const string GetUserInfos = "GetUserInfos"; } diff --git a/Extensions/xIdentityModelsExtensions.cs b/Extensions/xIdentityModelsExtensions.cs index 1058cf4..2314eff 100644 --- a/Extensions/xIdentityModelsExtensions.cs +++ b/Extensions/xIdentityModelsExtensions.cs @@ -385,6 +385,51 @@ namespace xIdentityModels.Extensions return result; } + /// + /// Check Dest Client IP is Exists in Source or not ... + /// + /// + /// + /// + public static bool IsClientIpPassed( + this IEnumerable source, + string dest + ) + { + // + // if Allowed IPs Empty means all Client IPs is Valid ... + var result = + !source.HasChild(); + if (result) + { + return result; + } + + // + result = !dest.IsNullOrEmpty(); + if (!result) + { + return result; + } + + // + result = source.Any(s => s.ToNormalString() == dest.ToNormalString()); + if (!result) + { + // + if (dest == "::1") + { + // + result = source.Any(s => + s.ToNormalString() == "127.0.0.1" || + s.ToNormalString() == "localhost"); + } + } + + // + return result; + } + /// /// Check Specified User Contains Specified UserSelectByParam or not ... ///