This commit is contained in:
2026-10-17 17:15:20 +03:30
parent 9fb70e14d7
commit 6203c7e084
4 changed files with 58 additions and 18 deletions
+2
View File
@@ -15,6 +15,8 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using xIdentityModels.Dtos;
using xIdentityService.Extensions;
namespace xIds.Providers
{
@@ -504,14 +504,9 @@ namespace xIds.Providers
? []
: requiredScope.ParseListString<string>();
//
// Audit Log ...
//
// Check Scope and IP is Valid or not ...
var isIpValid =
!allowedIps.HasChild() ||
allowedIps.Contains(clientIP);
var isIpValid = allowedIps.IsClientIpPassed(clientIP);
var isScopeValid =
allowedScopes
.IsScopePassed(requiredScopes);
@@ -1,10 +1,12 @@
using System;
using System.Linq;
using System.Threading;
using xCommons.Extensions;
using xIdentityModels.Dtos;
using xExceptions.Constants;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace xIds.Providers
{
@@ -71,6 +73,14 @@ namespace xIds.Providers
var responseJson = string.Empty;
switch (requestModel.Action)
{
//
case XOpenActions.GetApiKey:
//
ValidationProvider.NotEmpty(requestModel.Payload);
var apiKeyId = await GetApiKey(requestModel);
responseJson = apiKeyId.ToString();
break;
//
case XOpenActions.GetUserInfo:
//
@@ -129,6 +139,33 @@ namespace xIds.Providers
}
#endregion
/// <summary>
/// Get Specified Api Key ...
/// </summary>
/// <param name="model"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task<Guid> GetApiKey(
XOpenActionRequestDto model,
CancellationToken cancellationToken = default
)
{
//
var apiKey = await DbContext.ApiKeys
.FirstOrDefaultAsync(x =>
x.Key == model.Payload,
cancellationToken: cancellationToken
);
var result = Guid.Empty;
if (!apiKey.IsNullOrDefault())
{
result = apiKey.Id;
}
//
return result;
}
/// <summary>
/// Get User Info For Open Actions ...
/// </summary>