2023/04/08 1

[Spring Security] @AuthenticationPrincipal Test Trouble Shooting

๋“ค์–ด๊ฐ€๊ธฐ ์•ž์„œ ํ˜„์žฌ ํšŒ์‚ฌ์—์„œ๋Š” ์ž์ฒด์ ์ธ ํ† ํฐ ์ƒ์„ฑ ๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•ด ์œ ์ € ํ† ํฐ์„ ์ƒ์„ฑํ•˜๊ณ  ์ด๋ฅผ Memcached ์— ์ €์žฅํ•œ ๋’ค ์›น์ธ ๊ฒฝ์šฐ Cookie ๋ฅผ, ์•ฑ์ธ ๊ฒฝ์šฐ Http Header ์— ๋‹ด๊ธด ๊ฐ’์„ ํ†ตํ•ด ์œ ์ € ์ธ์ฆ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๋Š” ๊ตฌ์กฐ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์Šค์ผ€์ผ ์•„์›ƒ์œผ๋กœ ์„œ๋ฒ„๋ฅผ ์šด์˜ํ•˜๊ณ  ์žˆ์–ด ์œ ์ € ์ธ์ฆ ์ •๋ณด๋ฅผ ์—ฌ๋Ÿฌ ๋Œ€์˜ ์„œ๋ฒ„์—์„œ ํ•จ๊ป˜ ๊ณต์œ ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๋‹ค๋งŒ, ์œ ์ € ์ธ์ฆ/์ธ๊ฐ€ ์ฒ˜๋ฆฌ๋ฅผ Filter ๊ฐ€ ์•„๋‹Œ ๋ณ„๋„์˜ ์ธ์ฆ์šฉ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์ธ์ฆ ์ฒ˜๋ฆฌ ๋ฉ”์†Œ๋“œ์— @ModelAttribute ๋ฅผ ๋ถ™์—ฌ ๋งค ์š”์ฒญ ๋งˆ๋‹ค ์ธ์ฆ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๊ณ  ์žˆ์–ด ๋ถˆํ•„์š”ํ•œ ์ž์›์ด ๋‚ญ๋น„๋˜๊ณ  ์žˆ๋Š” ์ƒํ™ฉ์ด๋‹ค. ๋•Œ๋ฌธ์— Spring Security ์— ์ต์ˆ™์น˜๋„ ์•Š๊ณ , ์–ธ์  ๊ฐ€ ํšŒ์‚ฌ์˜ ๋ ˆ๊ฑฐ์‹œ ์ฝ”๋“œ๋ฅผ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„ ๋น„์‚ฌ์ด๋“œ ์‚ฌ์ด๋“œ ํ”„..

Programming/Spring 2023.04.08