260707_01_ENH: pkey 암호화, short url 생성에 api키 적용

This commit is contained in:
2026-07-07 11:45:28 +09:00
parent 1d5caeaa38
commit 07c3893132
4 changed files with 64 additions and 8 deletions

View File

@@ -16,13 +16,22 @@ namespace REPORT_API_ver6.Controllers
[Route("pkey")] [Route("pkey")]
[HttpGet] [HttpGet]
public IActionResult EncryptString([FromHeader] string token, [FromHeader]string pkey, [FromHeader]string iskiwi) public IActionResult EncryptString
(
[FromHeader(Name = "token")] string? token,
[FromHeader(Name = "X-API-Key")] string? xApiKey,
[FromHeader]string pkey,
[FromHeader]string iskiwi
)
{ {
HttpContextAccessor hcAccessor = new HttpContextAccessor(); HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain"; hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token); var configuration = Common.GetConfiguration();
if (userInfo != null) var value = configuration.GetSection("X-API-Key")[xApiKey ?? ""];
UserInfo? userInfo = String.IsNullOrEmpty(token)? null : Security.ValidateToken(token);
if (userInfo != null || !String.IsNullOrEmpty(value))
{ {
Project project = new Project(); Project project = new Project();
if (project.getProjectInfo(pkey, Convert.ToInt32(iskiwi)).Rows.Count > 0) if (project.getProjectInfo(pkey, Convert.ToInt32(iskiwi)).Rows.Count > 0)
@@ -35,7 +44,7 @@ namespace REPORT_API_ver6.Controllers
pkey = "|K|W|" + pkey; pkey = "|K|W|" + pkey;
} }
returnString = WebUtility.UrlEncode(security.encryptString(pkey)); returnString = WebUtility.UrlEncode(security.encryptString(pkey));
Response.StatusCode = (int)HttpStatusCode.OK; Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString); return Content(returnString);
} }

View File

@@ -18,19 +18,32 @@ namespace REPORT_API_ver6.Controllers
[Route("short")] [Route("short")]
[HttpPost] [HttpPost]
public IActionResult ShortURL([FromHeader] string token, [FromBody] ShortURLParam shortURLParam, [FromHeader] string skey) public IActionResult ShortURL
(
[FromHeader(Name = "token")] string? token,
[FromHeader(Name = "X-API-Key")] string? xApiKey,
[FromHeader] string skey,
[FromBody] ShortURLParam shortURLParam
)
{ {
HttpContextAccessor hcAccessor = new HttpContextAccessor(); HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain"; hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token); var configuration = Common.GetConfiguration();
if (userInfo != null) var value = configuration.GetSection("X-API-Key")[xApiKey ?? ""];
UserInfo? userInfo = String.IsNullOrEmpty(token)? null : Security.ValidateToken(token);
if (userInfo != null || !String.IsNullOrEmpty(value))
{ {
string okey = "REPORT"; string okey = "REPORT";
if(userInfo.ID == "KON" || userInfo.ID == "KIWI" || userInfo.ID == "NEWSSAK") if(userInfo.ID == "KON" || userInfo.ID == "KIWI" || userInfo.ID == "NEWSSAK")
{ {
okey = userInfo.ID; okey = userInfo.ID;
} }
else if(!String.IsNullOrEmpty(value))
{
okey = value;
}
PkeyInfo pkeyInfo = new PkeyInfo(skey); PkeyInfo pkeyInfo = new PkeyInfo(skey);
Project project = new Project(); Project project = new Project();

View File

@@ -0,0 +1,13 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
[JsonConverter(typeof(StringEnumConverter))]
public enum SortDirection
{
[EnumMember(Value = "asc")]
Asc,
[EnumMember(Value = "desc")]
Desc
}

View File

@@ -12,4 +12,25 @@ public class DataTabelToExcelSheet
SheetName = sheetName; SheetName = sheetName;
} }
public DataTabelToExcelSheet() { } public DataTabelToExcelSheet() { }
}
public class PageRequest
{
public int PageIndex { get; set; }
public int PageSize { get; set; }
public string SortBy {get; set; } = string.Empty;
public SortDirection SortDir { get; set; }
}
public class PageResponseDto<T>
{
public List<T> Content { get; set; } = new List<T>();
public int TotalElements { get; set; }
public int TotalPages { get; set; }
public int PageIndex { get; set; }
public int PageSize { get; set; }
public int NumberOfElements { get; set; }
public bool First { get; set; }
public bool Last { get; set; }
public bool Empty { get; set; }
} }