Arthur's Blog

Jwt Filter๊ฐ€ ๋‘ ๋ฒˆ ํ˜ธ์ถœ๋  ๋•Œ ๋ณธ๋ฌธ

Backend/Spring Boot

Jwt Filter๊ฐ€ ๋‘ ๋ฒˆ ํ˜ธ์ถœ๋  ๋•Œ

Leeseojune53 2023. 6. 29. 23:25

๐Ÿ› ๋ฌธ์ œ ์ƒํ™ฉ

Jwt Filter๊ฐ€ ์ธ์ฆ ๊ณผ์ •์—์„œ ๋‘ ๋ฒˆ ํ˜ธ์ถœ์ด ๋œ๋‹ค.

๐Ÿด‍โ˜ ๏ธ ์›์ธ

Filter๊ฐ€ ๋‘ ๋ฒˆ ๋“ฑ๋ก๋˜์–ด์„œ ๋‘ ๋ฒˆ ํ˜ธ์ถœ์ด ๋œ๋‹ค.

๋‘ ๋ฒˆ ๋“ฑ๋ก๋œ ์ด์œ ๋Š” builder.addFilterBefore(filter, UsernamePasswordAuthenticationFilter.class);์™€ ๊ฐ™์ด ํ•„ํ„ฐ๋ฅผ ๋“ฑ๋กํ–ˆ์ง€๋งŒ, ํ•„ํ„ฐ ์ƒ๋‹จ์˜ @Component ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ ์ธํ•ด Filter Chain์˜ ๋งจ ๋งˆ์ง€๋ง‰์— ํ•œ๋ฒˆ ๋” ๋“ฑ๋ก๋˜๋ฏ€๋กœ.

โ™ป ํ•ด๊ฒฐ๋ฒ•

@Component ์–ด๋…ธํ…Œ์ด์…˜์„ ์ œ๊ฑฐํ•œ๋‹ค.