Spring Security

์˜ค๋žœ๋งŒ์— SpringBoot๋กœ ๊ฐœ๋ฐœํ•˜๊ฒŒ ๋œ ๊ธฐ๋…์œผ๋กœ(?) ๋‹ค์‹œ ์ •๋ฆฌํ•˜๊ธฐ!

References: bamdule.tistory.com, [์ฑ…] ์ฝ”๋“œ๋กœ ๋ฐฐ์šฐ๋Š” ์Šคํ”„๋ง ์›น ํ”„๋กœ์ ํŠธ

What is Spring Security?

  • Spring ๊ธฐ๋ฐ˜์˜ application ๋ณด์•ˆ์„ ๋‹ด๋‹นํ•˜๋Š” framework

  • ์‚ฌ์šฉ์ž ์ธ์ฆ / ๊ถŒํ•œ / ๋ณด์•ˆ์ฒ˜๋ฆฌ๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค!

  • Filter ๊ธฐ๋ฐ˜์ด๋ผ์„œ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— Spring MVC์™€๋Š” ๋ถ„๋ฆฌ๋˜์–ด ๋™์ž‘

Security Terms

  1. Principal (์ ‘๊ทผ ์ฃผ์ฒด)

    • ๋ณด์•ˆ ์‹œ์Šคํ…œ์ด ์ž‘๋™๋˜๊ณ  ์žˆ๋Š” application์— ์ ‘๊ทผํ•˜๋Š” user

  2. Authentication (์ธ์ฆ)

    • ์ ‘๊ทผํ•œ user๋ฅผ ์‹๋ณ„ํ•˜๊ณ , application์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ

  3. Authorize (์ธ๊ฐ€)

    • ์ธ์ฆ๋œ user๊ฐ€ application์˜ ๊ธฐ๋Šฅ์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ๊ฒ€์‚ฌ

How Spring Security Works?

  • Servlet์˜ ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ filter์™€ interceptor ๋ฅผ ์ด์šฉํ•ด์„œ ์ฒ˜๋ฆฌ๋จ

    • Filter

      • Servlet ์—์„œ ๋งํ•˜๋Š” ๋‹จ์ˆœํ•œ ํ•„ํ„ฐ

      • Spring ๊ณผ๋Š” ๋ฌด๊ด€ํ•˜๊ฒŒ Servlet ์ž์›์ž„

    • Interceptor

      • ์Šคํ”„๋ง์—์„œ ํ•„ํ„ฐ์™€ ์—ญํ• ์„ ํ•จ

      • Spring์˜ Bean์œผ๋กœ ๊ด€๋ฆฌ๋˜๋ฉด์„œ Spring Context ๋‚ด์— ์†ํ•จ

  • Spring Security๋ฅผ ์ด์šฉํ•˜๊ฒŒ ๋˜๋ฉด Interceptor์™€ Filter๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ณ„๋„์˜ Context๋ฅผ ์ƒ์„ฑํ•ด ์ฒ˜๋ฆฌ๋จ

  • Spring Security๋Š” ํ˜„์žฌ ๋™์ž‘ํ•˜๋Š” Spring Context ๋‚ด์—์„œ ๋™์ž‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฏธ context์— ํฌํ•จ๋œ ์—ฌ๋Ÿฌ ๋นˆ๋“ค์„ ๊ฐ™์ด ์ด์šฉํ•ด์„œ ๋‹ค์–‘ํ•œ ๋ฐฉ์‹์˜ ์ธ์ฆ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋„๋ก ์„ค๊ณ„ํ•  ์ˆ˜ ์žˆ๋‹ค!

Last updated