Refactor and Test Application Controller and ApiKey Access Authorization Handling ...

This commit is contained in:
2026-10-17 01:18:14 +03:30
parent 6b648ede44
commit 9fb70e14d7
5 changed files with 94 additions and 18 deletions
+62 -13
View File
@@ -1,18 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using xCommons.Configurations;
using xCommons.Constants;
using xCommons.Controllers;
using xCommons.Extensions;
using xCommons.Providers;
using xExceptions.Constants;
using xIdentityModels.Constants;
using xIdentityModels.Models;
using xIds.Interfaces;
using xCommons.Providers;
using xCommons.Constants;
using xCommons.Extensions;
using xCommons.Controllers;
using xExceptions.Constants;
using System.Threading.Tasks;
using xIdentityModels.Models;
using xCommons.Configurations;
using Microsoft.AspNetCore.Mvc;
using xIdentityModels.Constants;
using System.Collections.Generic;
using xIdentityService.Constants;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authentication;
namespace xIds.Controllers.Base
{
@@ -226,6 +227,54 @@ namespace xIds.Controllers.Base
//
#region NonActions ...
/// <summary>
/// Extract Checksum From Headers ...
/// </summary>
/// <returns></returns>
[NonAction]
public string GetRequestChecksum()
{
//
var result = string.Empty;
//
var headerKey = XHeader.ChecksumDigest.GetStringValue();
//
// Check if Connection ID is Provided ...
if (Request.Headers.ContainsKey(headerKey))
{
result = Request.Headers[headerKey];
}
//
return result;
}
/// <summary>
/// Extract ApiKey From Headers ...
/// </summary>
/// <returns></returns>
[NonAction]
public string GetRequestApiKey()
{
//
var result = string.Empty;
//
var headerKey = XHeader.ApiKey.GetStringValue();
//
// Check if Connection ID is Provided ...
if (Request.Headers.ContainsKey(headerKey))
{
result = Request.Headers[headerKey];
}
//
return result;
}
/// <summary>
/// Convert an Exception to Propper Error Result
/// </summary>