This commit is contained in:
2026-10-16 21:34:06 +03:30
parent be3fd31b4e
commit 6b648ede44
6 changed files with 80 additions and 31 deletions
+8 -8
View File
@@ -1,6 +1,7 @@
using System;
using IdentityModel;
using xIds.Interfaces;
using System.Threading;
using xCommons.Constants;
using xCommons.Extensions;
using xExceptions.Constants;
@@ -13,7 +14,6 @@ using xIdentityService.Constants;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Authorization;
using System.Threading;
namespace xIds.Providers
{
@@ -36,7 +36,7 @@ namespace xIds.Providers
//
if (!scopes.HasChild())
{
scopes = [XApiKeyScope.Manage];
scopes = [XApiKeyScope.Read];
}
//
@@ -84,7 +84,7 @@ namespace xIds.Providers
{
//
error.Message = "Api Key Service not Registered ...";
context.Result = new UnauthorizedObjectResult(error.ToJSON());
context.Result = new UnauthorizedObjectResult(error);
return;
}
@@ -95,7 +95,7 @@ namespace xIds.Providers
{
//
error.Message = "ApiKey not Exists ...";
context.Result = new UnauthorizedObjectResult(error.ToJSON());
context.Result = new UnauthorizedObjectResult(error);
return;
}
@@ -106,7 +106,7 @@ namespace xIds.Providers
{
//
error.Message = "ApiKey not Provided ...";
context.Result = new UnauthorizedObjectResult(error.ToJSON());
context.Result = new UnauthorizedObjectResult(error);
return;
}
@@ -131,9 +131,9 @@ namespace xIds.Providers
if (validationResult.Errors.HasChild())
{
//
var message = validationResult.Errors.ToListString('\n');
var message = validationResult.Errors.ToListString(',');
error.Message = message;
context.Result = new UnauthorizedObjectResult(error.ToJSON());
context.Result = new UnauthorizedObjectResult(error);
return;
}
@@ -175,7 +175,7 @@ namespace xIds.Providers
{
//
error.Message = "ApiKey authorization failed ...";
context.Result = new UnauthorizedObjectResult(error.ToJSON());
context.Result = new UnauthorizedObjectResult(error);
}
}
}
@@ -512,13 +512,10 @@ namespace xIds.Providers
var isIpValid =
!allowedIps.HasChild() ||
allowedIps.Contains(clientIP);
var isScopeValid =
!allowedScopes.HasChild() ||
requiredScope.IsNullOrEmpty() ||
requiredScopes
.All(ts => allowedScopes
.Any(asc => asc.ToNormalString() == ts.ToNormalString()));
var isScopeIpValid =
var isScopeValid =
allowedScopes
.IsScopePassed(requiredScopes);
var isScopeIpValid =
isIpValid &&
isScopeValid
;
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using xCommons.Extensions;
using xExceptions.Constants;
using xIdentityModels.Dtos;
using xExceptions.Constants;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace xIds.Providers
{
@@ -12,6 +12,11 @@ namespace xIds.Providers
{
//
#region OpenGet ...
/// <summary>
/// Get Open Action ...
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<XOpenActionInnerDto> OpenGet(
XOpenActionInnerDto model
)
@@ -32,7 +37,12 @@ namespace xIds.Providers
);
}
//
/// <summary>
/// Get Open Action ...
/// </summary>
/// <param name="token"></param>
/// <param name="actionRequest"></param>
/// <returns></returns>
public async Task<XOpenActionInnerDto> OpenGet(
string token,
string actionRequest
@@ -119,6 +129,11 @@ namespace xIds.Providers
}
#endregion
/// <summary>
/// Get User Info For Open Actions ...
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<XOpenActionUserInfoDto> GetUserInfo(
XOpenActionRequestDto model
)
@@ -147,6 +162,11 @@ namespace xIds.Providers
return result;
}
/// <summary>
/// Retrieve a Collection of Open Actions User Info by Providing Ids ...
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<IEnumerable<XOpenActionUserInfoDto>> GetUserInfos(
XOpenActionRequestDto model
)
@@ -174,6 +194,12 @@ namespace xIds.Providers
//
#region Private ...
/// <summary>
/// Parse Models ...
/// </summary>
/// <param name="token"></param>
/// <param name="request"></param>
/// <returns></returns>
private XOpenActionRequestDto ParseModel(
string token,
string request