diff --git a/Interfaces/IXIdentityManager.cs b/Interfaces/IXIdentityManager.cs index e809adb..69286f9 100644 --- a/Interfaces/IXIdentityManager.cs +++ b/Interfaces/IXIdentityManager.cs @@ -1,22 +1,23 @@ using System; -using System.Collections.Generic; using System.Linq; +using xModels.Dtos; +using xIds.DbContext; using System.Net.Http; +using xIdentityModels; +using System.Threading; +using xCommons.Providers; +using IdentityModel.Client; +using xIdentityModels.Dtos; using System.Security.Claims; 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 Microsoft.AspNetCore.Http; +using xIdentityModels.Constants; +using System.Collections.Generic; +using xIdentityModels.Descriptors; using xIdentityModels.Navigations; -using xIds.DbContext; -using xModels.Dtos; +using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Identity; namespace xIds.Interfaces { @@ -462,6 +463,11 @@ namespace xIds.Interfaces ); #endregion + Task GetApiKey( + XOpenActionRequestDto dto, + CancellationToken cancellationToken = default + ); + Task GetUserInfo( XOpenActionRequestDto dto ); diff --git a/Providers/XApiKeyAccessAttribute.cs b/Providers/XApiKeyAccessAttribute.cs index 407472b..680a4de 100644 --- a/Providers/XApiKeyAccessAttribute.cs +++ b/Providers/XApiKeyAccessAttribute.cs @@ -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 { diff --git a/Providers/XApplicationProvider/XApplicationProvider+Custom.cs b/Providers/XApplicationProvider/XApplicationProvider+Custom.cs index b3ba941..15f6f85 100644 --- a/Providers/XApplicationProvider/XApplicationProvider+Custom.cs +++ b/Providers/XApplicationProvider/XApplicationProvider+Custom.cs @@ -504,14 +504,9 @@ namespace xIds.Providers ? [] : requiredScope.ParseListString(); - // - // 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); diff --git a/Providers/XIdentityManager/XIdentityManager+Open.cs b/Providers/XIdentityManager/XIdentityManager+Open.cs index cdc963e..9acb7c7 100644 --- a/Providers/XIdentityManager/XIdentityManager+Open.cs +++ b/Providers/XIdentityManager/XIdentityManager+Open.cs @@ -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 + /// + /// Get Specified Api Key ... + /// + /// + /// + /// + public async Task 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; + } + /// /// Get User Info For Open Actions ... ///