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

@@ -18,19 +18,32 @@ namespace REPORT_API_ver6.Controllers
[Route("short")]
[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();
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))
{
string okey = "REPORT";
if(userInfo.ID == "KON" || userInfo.ID == "KIWI" || userInfo.ID == "NEWSSAK")
{
okey = userInfo.ID;
}
else if(!String.IsNullOrEmpty(value))
{
okey = value;
}
PkeyInfo pkeyInfo = new PkeyInfo(skey);
Project project = new Project();