Compare commits

..
1 Commits
Author SHA1 Message Date
saherelm 6203c7e084 last ... 2026-10-17 17:15:20 +03:30
4 changed files with 58 additions and 18 deletions
+18 -12
View File
@@ -1,22 +1,23 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using xModels.Dtos;
using xIds.DbContext;
using System.Net.Http; using System.Net.Http;
using xIdentityModels;
using System.Threading;
using xCommons.Providers;
using IdentityModel.Client;
using xIdentityModels.Dtos;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using IdentityModel.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using xCommons.Providers;
using xIdentityModels;
using xIdentityModels.Constants;
using xIdentityModels.Descriptors;
using xIdentityModels.Dtos;
using xIdentityModels.Models; using xIdentityModels.Models;
using Microsoft.AspNetCore.Http;
using xIdentityModels.Constants;
using System.Collections.Generic;
using xIdentityModels.Descriptors;
using xIdentityModels.Navigations; using xIdentityModels.Navigations;
using xIds.DbContext; using Microsoft.Extensions.Logging;
using xModels.Dtos; using Microsoft.AspNetCore.Identity;
namespace xIds.Interfaces namespace xIds.Interfaces
{ {
@@ -462,6 +463,11 @@ namespace xIds.Interfaces
); );
#endregion #endregion
Task<Guid> GetApiKey(
XOpenActionRequestDto dto,
CancellationToken cancellationToken = default
);
Task<XOpenActionUserInfoDto> GetUserInfo( Task<XOpenActionUserInfoDto> GetUserInfo(
XOpenActionRequestDto dto XOpenActionRequestDto dto
); );
+2
View File
@@ -15,6 +15,8 @@ using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using xIdentityModels.Dtos;
using xIdentityService.Extensions;
namespace xIds.Providers namespace xIds.Providers
{ {
@@ -504,14 +504,9 @@ namespace xIds.Providers
? [] ? []
: requiredScope.ParseListString<string>(); : requiredScope.ParseListString<string>();
//
// Audit Log ...
// //
// Check Scope and IP is Valid or not ... // Check Scope and IP is Valid or not ...
var isIpValid = var isIpValid = allowedIps.IsClientIpPassed(clientIP);
!allowedIps.HasChild() ||
allowedIps.Contains(clientIP);
var isScopeValid = var isScopeValid =
allowedScopes allowedScopes
.IsScopePassed(requiredScopes); .IsScopePassed(requiredScopes);
@@ -1,10 +1,12 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading;
using xCommons.Extensions; using xCommons.Extensions;
using xIdentityModels.Dtos; using xIdentityModels.Dtos;
using xExceptions.Constants; using xExceptions.Constants;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace xIds.Providers namespace xIds.Providers
{ {
@@ -71,6 +73,14 @@ namespace xIds.Providers
var responseJson = string.Empty; var responseJson = string.Empty;
switch (requestModel.Action) switch (requestModel.Action)
{ {
//
case XOpenActions.GetApiKey:
//
ValidationProvider.NotEmpty(requestModel.Payload);
var apiKeyId = await GetApiKey(requestModel);
responseJson = apiKeyId.ToString();
break;
// //
case XOpenActions.GetUserInfo: case XOpenActions.GetUserInfo:
// //
@@ -129,6 +139,33 @@ namespace xIds.Providers
} }
#endregion #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> /// <summary>
/// Get User Info For Open Actions ... /// Get User Info For Open Actions ...
/// </summary> /// </summary>