Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Latest commit

ย 

History

History
104 lines (65 loc) ยท 6.45 KB

README.md

File metadata and controls

104 lines (65 loc) ยท 6.45 KB

yesaladin_auth

YesAladin Auth๋Š” ๋ถ„์‚ฐ ์„œ๋ฒ„ ํ™˜๊ฒฝ์œผ๋กœ ๊ตฌ์ถ•๋œ YesAladin ์„œ๋น„์Šค์˜ ์ธ์ฆ/์ธ๊ฐ€ ์ฒ˜๋ฆฌ๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์‹œ์Šคํ…œ ์ž…๋‹ˆ๋‹ค. Spring Security์— JWT ์ธ์ฆ ๋ฐฉ์‹์„ ์ ์šฉํ•˜์—ฌ Client์˜ Login/Logout ์š”์ฒญ์„ ์ˆ˜ํ–‰ํ•˜๋ฉฐ JWT ํ† ํฐ์„ ์ œ๊ณต ๋ฐ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

Getting Started

./mvnw spring-boot:run

Scheduling

  • NHN Dooray!์˜ ์นธ๋ฐ˜ ํ™œ์šฉ

image

image

Features

  • JWT ์ธ์ฆ ์„œ๋ฒ„ ๊ตฌ์ถ•
    • Client์˜ Login / Logout ์š”์ฒญ ์ˆ˜ํ–‰ ๋ฐ JWT ํ† ํฐ ๊ด€๋ฆฌ
    • Front Server์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ๊ฐ–๊ณ  ์žˆ๋Š” ํ† ํฐ์— ๋Œ€ํ•œ ์žฌ๋ฐœ๊ธ‰ API ์ œ๊ณต
  • NHN Cloud Log & Crash๋ฅผ ์—ฐ๋™ํ•˜์—ฌ ๋ชจ๋‹ˆํ„ฐ๋ง ํ™˜๊ฒฝ ๊ตฌ์ถ•
  • Spring Cloud Config๋ฅผ ์—ฐ๋™ํ•˜์—ฌ ์„ค์ • ์ •๋ณด ์™ธ๋ถ€ํ™”
  • Shop API Server๋กœ๋ถ€ํ„ฐ ์œ„์ž„ ๋ฐ›์€ ์ธ๊ฐ€ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ JWT ํ† ํฐ ๊ฒ€์ฆ ๋ฐ payload ๋ฐ˜ํ™˜ API ๊ตฌํ˜„

Project Architecture

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2023-02-22 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 10 15 46

CI/CD

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2023-02-22 แ„‹แ…ฉแ„’แ…ฎ 7 24 08

Technical Issue

๋ถ„์‚ฐ ์„œ๋ฒ„ ํ™˜๊ฒฝ์—์„œ์˜ ์ธ์ฆ/์ธ๊ฐ€

Front Server์—์„œ์˜ ์‚ฌ์šฉ์ž ์š”์ฒญ์„ ๋ฐ›์•„ ์œ ํšจํ•œ ์š”์ฒญ์ธ์ง€์˜ ์—ฌ๋ถ€๋ฅผ ํŒ๋ณ„ํ•˜๊ณ , JWT๋ฅผ ๋ฐœ๊ธ‰์‹œ์ผœ์ฃผ๊ธฐ ์œ„ํ•ด UsernamePasswordAuthenticationFilter๋ฅผ Customizing ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉ์ž ์ •๋ณด์— ๋Œ€ํ•œ Database๋Š” Shop API Server์— ์ข…์†๋˜์–ด ์žˆ์–ด ๋‚ด๋ถ€์  flow๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
AuthenticationProvider์— ์˜ํ•ด ์ฑ…์ž„์„ ๋ฐ›์€ UserDetailsService๋ฅผ Customํ•œ ๊ณณ์—์„œ RestTemplate์œผ๋กœ API ํ˜ธ์ถœ ํ›„ ์ธ์ฆ ๊ณผ์ •์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. Spring Security๋ฅผ ์ ์šฉํ•œ ์„œ๋ฒ„๋Š” Front Server, Shop API Server, Auth Server์ด๊ณ  Front Server๋ฅผ ์ œ์™ธํ•œ ๊ฐ ์„œ๋ฒ„๋Š” Session ์œ ์ง€๋ฐฉ์‹์„ Stateless๋กœ ๊ณ ์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Front Server์˜ ๊ฒฝ์šฐ Vue.js, React.js ๋“ฑ๊ณผ ๊ฐ™์€ Frontend Framework๊ฐ€ ์•„๋‹Œ Spring Boot + Thymeleaf ๊ธฐ๋ฐ˜์˜ ์„œ๋ฒ„์ด๊ธฐ ๋•Œ๋ฌธ์— ์ธ์ฆ/์ธ๊ฐ€ ์š”์ฒญ ์ดํ›„ ๋ฐœ๊ธ‰๋œ JWT๋ฅผ ์ง์ ‘์ ์œผ๋กœ Http Body์— ๋„ฃ์–ด ๋„˜๊ฒจ์ฃผ์ง€ ์•Š๊ณ  ํšŒ์›๋งˆ๋‹ค ๊ณ ์œ ํ•˜๊ฒŒ ๋ฐœ๊ธ‰๋œ uuid์™€ accessToken๊ณผ ๊ฐ™์€ ์ •๋ณด๋งŒ์„ HTTP Header์— ๋„ฃ์–ด return ํ•ฉ๋‹ˆ๋‹ค. Front Server๋Š” ๋ฐœ๊ธ‰๋ฐ›์€ JWT๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ Session ๋ฐ Cookie๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํšŒ์›์˜ ๋กœ๊ทธ์ธ์„ ์œ ์ง€ํ•˜๋„๋ก ์„ค๊ณ„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ, Front Server์˜ scale out์œผ๋กœ ์ธํ•ด ๋กœ๊ทธ์ธ์„ ์œ ์ง€ํ•˜๊ธฐ ์–ด๋ ต๋‹ค๋Š” ๋ฌธ์ œ๋กœ Redis๋ฅผ ๊ณต์œ  ์„ธ์…˜ ์ €์žฅ์†Œ๋กœ ์‚ฌ์šฉํ•˜์˜€๊ณ , ์‚ฌ์šฉ์ž๋Š” Auth Server๋กœ๋ถ€ํ„ฐ ๋ธŒ๋ผ์šฐ์ €์— Cookie๋กœ ๋ฐœ๊ธ‰๋œ uuid key๋ฅผ ๊ธฐ์ค€์œผ๋กœ Redis Session์— ์ ‘๊ทผํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋กœ๊ทธ์ธ/๋กœ๊ทธ์•„์›ƒ, ํ† ํฐ ์žฌ๋ฐœ๊ธ‰์˜ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

ํ† ํฐ ์žฌ๋ฐœ๊ธ‰์˜ ๊ฒฝ์šฐ, JWT์˜ accessToken, refreshToken์„ ํ† ๋Œ€๋กœ accessToken์˜ ์œ ํšจํ•œ ํƒ€์ž„์„ ๊ธฐ์ค€์œผ๋กœ Front Server์— ๊ตฌํ˜„ํ–ˆ๋˜ Interceptor๋ฅผ ํ†ตํ•ด ์‚ฌ์ „์— ์žฌ๋ฐœ๊ธ‰ ํ•ด์•ผ ํ•˜๋Š” ์‹œ์ ์ธ์ง€ ํŒ๋ณ„ํ•˜๊ณ , ์ด์— ํ•ด๋‹นํ•˜๋ฉด ์ž๋™์œผ๋กœ Auth Server์— ์žฌ๋ฐœ๊ธ‰ ์š”์ฒญ์„ ๋ณด๋‚ด ์‘๋‹ต๋ฐ›์€ ๋’ค, ๋‹ค์Œ ๊ณผ์ •๋“ค(ํŽ˜์ด์ง€ ์ด๋™, Shop API ํ˜ธ์ถœ ๋“ฑ)์„ ์ˆ˜ํ–‰ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

Shop API Server๋Š” Front Server๋กœ๋ถ€ํ„ฐ Authorization Header์— ๋‹ด๊ธด JWT ํ† ํฐ ์ •๋ณด๋ฅผ ๋ฐ›์•„ ์ด์— ๋Œ€ํ•œ ์ธ๊ฐ€ ์ฒ˜๋ฆฌ๋ฅผ ์‚ฌ์ „์— Auth Server๋กœ ์œ„์ž„ํ•ฉ๋‹ˆ๋‹ค. Auth Server์—์„œ ํ•ด๋‹น JWT ํ† ํฐ์˜ ์œ ํšจ์„ฑ ๊ฒ€์ฆ์ด ์™„๋ฃŒ๋˜์–ด ์ธ๊ฐ€ ๋œ ๊ฒฝ์šฐ, payload์— ๋“ค์–ด์žˆ๋Š” ์‚ฌ์šฉ์ž ์‹๋ณ„ ์ •๋ณด์™€ ๊ถŒํ•œ ์ •๋ณด๋ฅผ ์ถ”์ถœํ•˜์—ฌ Shop API Server์— ๋Œ๋ ค์ค๋‹ˆ๋‹ค. ์ด ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ Shop API Server ๋‚ด์—์„œ Spring Security๋ฅผ ํ†ตํ•ด ์ž์ฒด์ ์œผ๋กœ Authentication ์„ ์ƒ์„ฑํ•˜๋„๋ก ์ฒ˜๋ฆฌํ•˜์˜€์œผ๋ฉฐ, FilterSecurityInterceptor ๋ฐ method security๋ฅผ ์ ์šฉํ•˜์—ฌ API ๋ณด์•ˆ์„ ๊ฐ•ํ™”ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Tech Stack

Languages

Java

Frameworks

SpringBoot Spring Security SpringCloud

Build Tool

ApacheMaven

Authentication

JWT

Database

Redis

DevOps

NHN Cloud Jenkins SonarQube Grafana

ํ˜•์ƒ ๊ด€๋ฆฌ ์ „๋žต

Git GitHub

  • Git Flow ์ „๋žต์„ ์‚ฌ์šฉํ•˜์—ฌ Branch๋ฅผ ๊ด€๋ฆฌํ•˜๋ฉฐ Main/Develop Branch๋กœ Pull Request ์‹œ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ง„ํ–‰ ํ›„ merge ํ•ฉ๋‹ˆ๋‹ค. image
  • Main: ๋ฐฐํฌ์‹œ ์‚ฌ์šฉ
  • Develop: ๊ฐœ๋ฐœ ๋‹จ๊ณ„๊ฐ€ ๋๋‚œ ๋ถ€๋ถ„์— ๋Œ€ํ•ด Merge ๋‚ด์šฉ ํฌํ•จ
  • Feature: ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ ๋‹จ๊ณ„
  • Hot-Fix: Merge ํ›„ ๋ฐœ์ƒํ•œ ๋ฒ„๊ทธ ๋ฐ ์ˆ˜์ • ์‚ฌํ•ญ ๋ฐ˜์˜ ์‹œ ์‚ฌ์šฉ

Contributors