Skip to content

Commit

Permalink
feat: add jwt-signature-verification docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yeeun kang committed Nov 15, 2024
1 parent 2c49028 commit d30455b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/response-time-by-algorithm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/response-time-by-memory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/tips/jwt-signature-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
layout: default
title: JWT Signature Verification
parent: Tips
---
# Research on Efficient JWT Signature Verification in Serverless Microservices

## ๐Ÿ“„ Abstract

์ด ์—ฐ๊ตฌ๋Š” ์„œ๋ฒ„๋ฆฌ์Šค ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ์•„ํ‚คํ…์ฒ˜(MSA)์—์„œ ํšจ์œจ์ ์ธ JWT ์„œ๋ช… ๊ฒ€์ฆ ๋ฐฉ๋ฒ•์„ ์ œ์‹œํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ AWS Lambda ๋ฉ”๋ชจ๋ฆฌ ์„ค์ •๊ณผ ์„œ๋ช… ์•Œ๊ณ ๋ฆฌ์ฆ˜(RS256, RS512)์„ ์‚ฌ์šฉํ•˜์—ฌ JWT ๊ฒ€์ฆ ์„ฑ๋Šฅ์„ ๋ถ„์„ํ•˜์˜€์œผ๋ฉฐ, AWS KMS ๊ธฐ๋ฐ˜ ๊ฒ€์ฆ๊ณผ ์ž์ฒด ์„œ๋ช… ๊ฒ€์ฆ ๋ฐฉ์‹์„ ๋น„๊ตํ•˜์˜€์Šต๋‹ˆ๋‹ค.

## ๐Ÿ› ๏ธ Experimental Setup

### 1. Environment Configuration
- **Infrastructure**: AWS Lambda
- **Automation Tools**: Terraform, Serverless Framework
- **Runtime**: Node.js 18
- **Memory Settings**: 128MB, 256MB, 512MB, 1024MB, 2048MB

### 2. JWT Verification Methods
- **No Verification**: ๊ฒ€์ฆ์„ ์ˆ˜ํ–‰ํ•˜์ง€ ์•Š๋Š” ๋Œ€์กฐ๊ตฐ
- **KMS Verification**: AWS KMS๋ฅผ ์‚ฌ์šฉํ•œ ์„œ๋ช… ๊ฒ€์ฆ
- **Self-Signing Verification**: ๊ณต๊ฐœ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•œ ์ž์ฒด ์„œ๋ช… ๊ฒ€์ฆ

### 3. Signature Algorithms
- **RS256**: RSA-SHA256 ์•Œ๊ณ ๋ฆฌ์ฆ˜
- **RS512**: RSA-SHA512 ์•Œ๊ณ ๋ฆฌ์ฆ˜

## ๐Ÿ“Š Results Analysis

![Response Time by Algorithm](assets/images/response-time-by-algorithm.png)
### 1. Verification Method Comparison
- **Self-Signing Verification** ๋ฐฉ์‹์€ ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์ด ์—†์–ด ๊ฐ€์žฅ ๋น ๋ฅด๊ณ  ์•ˆ์ •์ ์ธ ์„ฑ๋Šฅ์„ ๋ณด์˜€์Šต๋‹ˆ๋‹ค.
- ํ‰๊ท  ์‘๋‹ต ์‹œ๊ฐ„์ด ๊ฐ€์žฅ ๋‚ฎ์•˜์œผ๋ฉฐ, ์˜ค์ฐจ ๋ฒ”์œ„(MAD)๋„ ์ž‘์•„ ๊ณ ๋นˆ๋„ ์š”์ฒญ์ด ๋ฐœ์ƒํ•˜๋Š” ํ™˜๊ฒฝ์—์„œ ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.
- **KMS Verification** ๋ฐฉ์‹์€ ๋†’์€ ๋ณด์•ˆ์„ฑ์„ ์ œ๊ณตํ•˜์ง€๋งŒ, AWS KMS API ํ˜ธ์ถœ๋กœ ์ธํ•œ ๋„คํŠธ์›Œํฌ ์ง€์—ฐ๊ณผ ์˜ค๋ฒ„ํ—ค๋“œ๋กœ ์ธํ•ด ์‘๋‹ต ์‹œ๊ฐ„์ด ์ฆ๊ฐ€ํ•˜๊ณ  ๋ณ€๋™์„ฑ์ด ์ปธ์Šต๋‹ˆ๋‹ค.

### 2. Signature Algorithm Performance
- **RS256**๊ณผ **RS512** ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐ„ ์„ฑ๋Šฅ ์ฐจ์ด๋Š” ๋ฏธ๋ฏธํ–ˆ์œผ๋‚˜, **RS512**๊ฐ€ ๋” ์ผ๊ด€๋œ ์„ฑ๋Šฅ์„ ๋ณด์˜€์Šต๋‹ˆ๋‹ค.
- RS512๋Š” ๋” ๊ฐ•๋ ฅํ•œ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด์ง€๋งŒ, ํšจ์œจ์ ์ธ ์„œ๋ช… ๊ฒ€์ฆ ๊ณผ์ • ๋•๋ถ„์— ์•ˆ์ •์ ์ธ ์‘๋‹ต ์‹œ๊ฐ„์„ ๊ธฐ๋กํ–ˆ์Šต๋‹ˆ๋‹ค.
- ๋ณด์•ˆ ์š”๊ตฌ ์‚ฌํ•ญ์ด ๋†’์€ ํ™˜๊ฒฝ์—์„œ๋Š” RS512 ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ ํ•ฉํ•œ ์„ ํƒ์ž…๋‹ˆ๋‹ค.

![Response Time by Memory](assets/images/response-time-by-memory.png)
### 3. Memory Allocation Impact
- ๋ฉ”๋ชจ๋ฆฌ ์šฉ๋Ÿ‰์ด **128MB**์ผ ๋•Œ, ๋ชจ๋“  ๊ฒ€์ฆ ๋ฐฉ์‹์—์„œ ๊ฐ€์žฅ ๊ธด ์‘๋‹ต ์‹œ๊ฐ„์„ ๊ธฐ๋กํ•˜์˜€์œผ๋ฉฐ, ํŠนํžˆ **KMS Verification**์—์„œ ์„ฑ๋Šฅ ์ €ํ•˜๊ฐ€ ๋‘๋“œ๋Ÿฌ์กŒ์Šต๋‹ˆ๋‹ค.
- **512MB** ์ด์ƒ์˜ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น์—์„œ๋Š” ์•ˆ์ •์ ์ธ ์„ฑ๋Šฅ์„ ๋ณด์˜€์œผ๋ฉฐ, ๋ฉ”๋ชจ๋ฆฌ ์ฆ๊ฐ€์— ๋”ฐ๋ฅธ ์„ฑ๋Šฅ ๊ฐœ์„  ํšจ๊ณผ๋Š” ๋ฏธ๋ฏธํ–ˆ์Šต๋‹ˆ๋‹ค.
- **2048MB** ๋ฉ”๋ชจ๋ฆฌ ์„ค์ •์—์„œ๋„ ๊ฐ„ํ—์  ์„ฑ๋Šฅ ์ŠคํŒŒ์ดํฌ๊ฐ€ ๊ด€์ฐฐ๋˜์—ˆ์œผ๋ฉฐ, ์ด๋Š” ๋„คํŠธ์›Œํฌ ์ƒํƒœ๋‚˜ AWS ๋‚ด๋ถ€ ์ฒ˜๋ฆฌ ์ง€์—ฐ์˜ ์˜ํ–ฅ์œผ๋กœ ๋ถ„์„๋ฉ๋‹ˆ๋‹ค.
- **512MB** ๋ฉ”๋ชจ๋ฆฌ ์„ค์ •์ด ์„ฑ๋Šฅ๊ณผ ๋น„์šฉ์˜ ๊ท ํ˜•์„ ๋งž์ถœ ์ˆ˜ ์žˆ๋Š” ํšจ์œจ์ ์ธ ์„ ํƒ์œผ๋กœ ๋‚˜ํƒ€๋‚ฌ์Šต๋‹ˆ๋‹ค.

![Response Time Change Over Load Increase](assets/images/response-time-change-over-load-increase.png)
### 4. Load Testing Analysis
- Artillery๋ฅผ ์‚ฌ์šฉํ•œ ๋ถ€ํ•˜ ํ…Œ์ŠคํŠธ์—์„œ, ์š”์ฒญ๋Ÿ‰ ์ฆ๊ฐ€์— ๋”ฐ๋ผ **Self-Signing Verification** ๋ฐฉ์‹์ด ๊ฐ€์žฅ ์ผ๊ด€๋œ ์„ฑ๋Šฅ์„ ๋ณด์˜€์Šต๋‹ˆ๋‹ค.
- **KMS Verification** ๋ฐฉ์‹์€ ๋„คํŠธ์›Œํฌ ์ง€์—ฐ๊ณผ AWS API ํ˜ธ์ถœ๋กœ ์ธํ•ด ์„ฑ๋Šฅ ๋ณ€๋™์ด ์ปธ์Šต๋‹ˆ๋‹ค.

## ๐Ÿ” Key Findings
- **KMS Verification** ๋ฐฉ์‹์€ ๋†’์€ ๋ณด์•ˆ์„ ์ œ๊ณตํ•˜์ง€๋งŒ, ๋„คํŠธ์›Œํฌ ์ง€์—ฐ๊ณผ ๋†’์€ ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ์œผ๋กœ ์ธํ•ด ์„ฑ๋Šฅ ์ €ํ•˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- **Self-Signing Verification** ๋ฐฉ์‹์€ ๋น„๊ต์  ๋‚ฎ์€ ์‘๋‹ต ์‹œ๊ฐ„๊ณผ ์ผ๊ด€๋œ ์„ฑ๋Šฅ์„ ์ œ๊ณตํ•˜์—ฌ, ๋ณด์•ˆ ์š”๊ตฌ ์‚ฌํ•ญ์ด ๋‚ฎ์€ ๊ฒฝ์šฐ ํšจ์œจ์ ์ธ ์„ ํƒ์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- **RS512** ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋” ๊ฐ•๋ ฅํ•œ ์•”ํ˜ธํ™”์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์•ˆ์ •์ ์ธ ์‘๋‹ต ์‹œ๊ฐ„์„ ๊ธฐ๋กํ•˜์˜€์Šต๋‹ˆ๋‹ค.
- ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น์ด 512MB ์ด์ƒ์ผ ๋•Œ, ์„ฑ๋Šฅ๊ณผ ๋น„์šฉ์˜ ๊ท ํ˜•์„ ๋งž์ถœ ์ˆ˜ ์žˆ๋Š” ์ตœ์ ์˜ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค.

0 comments on commit d30455b

Please sign in to comment.