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")]
[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();
hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
var configuration = Common.GetConfiguration();
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();
if (project.getProjectInfo(pkey, Convert.ToInt32(iskiwi)).Rows.Count > 0)
@@ -35,7 +44,7 @@ namespace REPORT_API_ver6.Controllers
pkey = "|K|W|" + pkey;
}
returnString = WebUtility.UrlEncode(security.encryptString(pkey));
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}