last ...
This commit is contained in:
@@ -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<Guid> GetApiKey(
|
||||
XOpenActionRequestDto dto,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||
XOpenActionRequestDto dto
|
||||
);
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user