๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

๊ฒฝํ—˜

ICT ๊ฐœ๋ฐœ์ž ์ง๋ฌดํŠน๊ฐ• ํ›„๊ธฐ - ์ข‹์€ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜๋Š” ๋ฐฉ๋ฒ• (๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์šฐ์ƒํ›ˆ๋‹˜)

์ด๋ฒˆ ํ•™๊ธฐ์—๋Š” ICT ์ธํ„ด์„ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ๋Š”๋ฐ ICT ์ธํ„ด๋“ค์„ ๋Œ€์ƒ์œผ๋กœ ์ง๋ฌด ํŠน๊ฐ•์„ ์—ฐ๋‹ค๊ณ  ํ•ด์„œ ๋‹ค๋…€์™”๋‹ค! ์˜ค์ „์— ์ถœ๊ทผํ–ˆ๋‹ค๊ฐ€ ๊ฐ•๋‚จ์œผ๋กœ ๋„˜์–ด๊ฐ”๋”๋‹ˆ ์˜คํ›„ ๋ฐ˜์ฐจ๋ฅผ ์“ด ๊ธฐ๋ถ„์ด์—ˆ๋‹ค ใ…Žใ……ใ…Ž ์—ญ์‹œ ์ •๋ถ€์—์„œ ์ง€์›ํ•˜๋Š”๊ฑฐ๋ผ ๊ทธ๋Ÿฐ์ง€ ์ปคํ”ผ, ๋ฌผ, ๊ณผ์ผ, ๊ณผ์ž, ์ ค๋ฆฌ... ๊ฐ„์‹์ด ์•„์ฃผ ๋„˜์ณ๋‚ฌ๋‹ค ๐Ÿท๐Ÿท ์ˆœ์„œ๋Š” ๋„ค์ด๋ฒ„-์นด์นด์˜ค-๋ผ์ธํ”Œ๋Ÿฌ์Šค ๊ฐœ๋ฐœ์ž ๋ถ„ ์ˆœ์„œ๋กœ ๊ฐ•์—ฐ์ด ์ด๋ฃจ์–ด์กŒ๋‹ค ๋‚˜๋Š” ๋‘์„ธ๋ฒˆ์งธ ๊ฐ•์—ฐ์„ ๋ฐฑ์—”๋“œ-์„œ๋ฒ„(๋ฐ์ดํ„ฐ)๋กœ ์„ ํƒํ•ด์„œ ๋“ค์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ํ”„๋ก ํŠธ๋‚˜ ์ธ๊ณต์ง€๋Šฅ ๋“ค์œผ์‹  ๋ถ„๋“ค์€ ๋‹ค๋ฅธ ๊ฐ•์˜๋ฅผ ๋“ค์—ˆ์„ ์ˆ˜๋„! ํŠน๊ฐ• ๋“ค์€ ๋‚ด์šฉ์„ ํ•œ ๋ฒˆ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ๊ธ€์„ ์“ด๋‹ค !! ์‚ฌ์‹ค ๋ฐฑ์—”๋“œ๋ž‘ ์„œ๋ฒ„ ๊ด€๋ จ๋œ ๋‚ด์šฉ์€ ๋‚ด๊ฐ€ ์ข€ ๋” ๊ณต๋ถ€๋ฅผ ํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ๋Š๊ผˆ์–ด์„œ ์ข‹์€ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜๊ธฐ ์œ„ํ•ด์„  ์–ด๋–ป๊ฒŒ ํ•ด์•ผ๋ ์ง€ ์ ์–ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค ใ…Žใ…Ž ๐ŸŒป ์ข‹์€ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜๋Š” ๋ฐฉ๋ฒ• - ์šฐ์ƒํ›ˆ๋‹˜ (๋„ค์ด๋ฒ„)..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) ์‚ฌ์šฉ์ž DB ๋“ฑ๋ก ๋ฐ PasswordEncoder

Form ์ธ์ฆ - PasswordEncoder ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์•”ํ˜ธํ™”ํ•˜๋„๋ก ์ œ๊ณต ์ƒ์„ฑ PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder() ์—ฌ๋Ÿฌ ๊ฐœ์˜ PasswordEncoder ์œ ํ˜•์„ ์„ ์–ธํ•œ ๋’ค, ์ƒํ™ฉ์— ๋งž๊ฒŒ ์„ ํƒํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•˜๋Š” Encoder์ด๋‹ค. ์•”ํ˜ธํ™” ํฌ๋งท {id}encodedPassword ๊ธฐ๋ณธ ํฌ๋งท์€ Bcrypt : {bcrypt}$2a@10~~~ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ข…๋ฅ˜ : bcrypt, noop, pbkdf2, scrypt, sha256 PasswordEncoder๋ฅผ ์ด์šฉํ•ด ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™”๋ฅผ ํ•œ ๋’ค ์‚ฌ์šฉ์ž๋ฅผ ์ €์žฅํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด! ์•„๋ž˜์™€ ๊ฐ™์ด ํ•˜๋ฉด ๋œ๋‹ค. (ํ•˜์ง€๋งŒ ์•„๋ž˜๋Š” ๊ฐ•์˜๋ฅผ..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) CSRF, CsrfFilter - ๋กœ๊ทธ์•„์›ƒ ์˜ˆ์ œ

๊ณต๊ฒฉ์˜ ์œ„ํ—˜์„ฑ ํ•ด๋‹น ๋กœ์ง์„ ํ†ตํ•ด์„œ ํ•ด์ปค๋“ค์ด ๊ณต๊ฒฉ์„ ํ•œ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์‡ผํ•‘๋ชฐ์— ๋กœ๊ทธ์ธํ•˜๊ณ  ๋‚˜์„œ ์ฟ ํ‚ค๋ฅผ ๋ฐœ๊ธ‰ํ•˜๋ฉด ์‚ฌ์šฉ์ž์˜ ๋ธŒ๋ผ์šฐ์ €์— ์ฟ ํ‚ค๊ฐ€ ์ €์žฅ๋œ๋‹ค. ๊ณต๊ฒฉ์ž๊ฐ€ ๋งํฌ๋ฅผ ์ด์šฉ์ž์—๊ฒŒ ์ „๋‹ฌํ•˜๊ณ  ์‚ฌ์šฉ์ž๋Š” ๋งํฌ๋ฅผ ํด๋ฆญํ•ด์„œ ๊ณต๊ฒฉ์šฉ ์›นํŽ˜์ด์ง€์— ์ ‘์†ํ•œ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋Š” ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•ด์„œ ๊ณต๊ฒฉ์šฉ url์„ ์—ด๊ณ  ์‡ผํ•‘๋ชฐ์€ ํ•ด๋‹น ์ฟ ํ‚ค๋ฅผ ๊ฐ€์ง„ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์˜์‹ฌํ•˜์ง€ ์•Š๊ณ  ์ธ์ฆ์„ ํ•œ๋‹ค. ์‹œํ๋ฆฌํ‹ฐ๋Š” ์ด๋Ÿฐ ๊ณต๊ฒฉ ๋ฐฉ์‹์„ ๋ฐฉ์–ดํ•˜๊ธฐ ์œ„ํ•ด์„œ CsrfFilter๋ฅผ ๋งŒ๋“ค์–ด์„œ csrf์˜ ์ทจ์•ฝ์ ์„ ๋ฐฉ์ง€ํ•˜๊ณ  ์žˆ๋‹ค. CsrfFilter ๋ชจ๋“  ์š”์ฒญ์— ๋žœ๋ค ํ•˜๊ฒŒ ์ƒ์„ฑ๋œ ํ† ํฐ์„ HTTP ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์š”๊ตฌ ์š”์ฒญ ์‹œ ์ „๋‹ฌ๋˜๋Š” ํ† ํฐ ๊ฐ’๊ณผ ์„œ๋ฒ„์— ์ €์žฅ๋œ ์‹ค์ œ ๊ฐ’๊ณผ ๋น„๊ตํ•œ ํ›„ ๋งŒ์•ฝ ์ผ์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด ์š”์ฒญ์€ ์‹คํŒจํ•จ HTTP ๋ฉ”์†Œ๋“œ : PATCH, POST, PUT, DE..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) ExceptionTraslationFilter, RequestCacheAwareFilter

๐ŸŒฑ ์˜ˆ์™ธ AuthenticationException ์ธ์ฆ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ AuthenticationEntryPoint ํ˜ธ์ถœ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ ์ด๋™, 401 ์˜ค๋ฅ˜ ์ฝ”๋“œ ์ „๋‹ฌ ๋“ฑ ์ธ์ฆ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๊ธฐ ์ „์˜ ์š”์ฒญ ์ •๋ณด๋ฅผ ์ €์žฅ RequestCache : ์‚ฌ์šฉ์ž ์ด์ „ ์š”์ฒญ ์ •๋ณด๋ฅผ ์„ธ์…˜์— ์ €์žฅํ•˜๊ณ  ์ด๋ฅผ ๊บผ๋‚ด์˜ค๋Š” ์บ์‹œ ๋ฉ”์ปค๋‹ˆ์ฆ˜ SavedRequest : ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญํ–ˆ๋˜ request ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’๋“ค, ๊ทธ ๋‹น์‹œ ํ—ค๋” ๊ฐ’๋“ค ๋“ฑ์ด ์ €์žฅ AccessDeniedExeption ์ธ๊ฐ€ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ AccessDeniedHandler์—์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌํ•˜๋„๋ก ์ œ๊ณต ๐Ÿ‘‰ ์ด๋Ÿฐ ์˜ˆ์™ธ๋Š” FilterSecurityInterceptor์—์„œ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ด ํ•„ํ„ฐ ์•ž์— ์žˆ๋Š” ํ•„ํ„ฐ๊ฐ€ ExceptionTranslationFilter์ž„ ๊ทธ๋ž˜์„œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด Filte..

๊ธฐํƒ€

Unable to create '/.git/index.lock': File exists.

์ปค๋ฐ‹์„ ํ•˜๋ ค๋‹ค๊ฐ€ ํ•ด๋‹น ๋ฌธ๊ตฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด์„œ ์ปค๋ฐ‹์ด ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค ์ด๋Ÿด ๊ฒฝ์šฐ์—๋Š” .git ํŒŒ์ผ์ด ์กด์žฌํ•˜๋Š” ํด๋”์—์„œ git bash๋ฅผ ์‹คํ–‰ํ•œ ๋‹ค์Œ์— ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋œ๋‹ค. rm -f ./.git/index.lock

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) ๊ถŒํ•œ์„ค์ •๊ณผ ํ‘œํ˜„์‹

๊ถŒํ•œ ์„ค์ • ๋ฐฉ์‹์—๋Š” ์„ ์–ธ์  ๋ฐฉ์‹๊ณผ ๋™์  ๋ฐฉ์‹์ด ์กด์žฌํ•œ๋‹ค. ์„ ์–ธ์  ๋ฐฉ์‹ URL http.antMatcher("/user/**).hasRole("USER") Method @PreAuthorize("hasRole('USER')") public void user() {System.out.println("user")} ๋™์  ๋ฐฉ์‹ - DB ์—ฐ๋™ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐฉ์‹ URL Method SecurityConfig @Override protected void configure(HttpSecurity http) throws Exception { http .antMatcher(“/shop/**”) .authorizeRequests() .antMatchers(“/shop/login”, “/shop/users/**”).permit..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) ๋™์‹œ ์„ธ์…˜ ์ œ์–ด, ์„ธ์…˜ ๊ณ ์ • ๋ณดํ˜ธ, ์„ธ์…˜ ์ •์ฑ…

๐ŸŽ  ๋™์‹œ ์„ธ์…˜ ์ œ์–ด ๋™์‹œ ์„ธ์…˜ ์ œ์–ด๋Š” ํ˜„์žฌ ๋™์ผํ•œ ๊ณ„์ •์œผ๋กœ ์ธ์ฆ์„ ๋ฐ›์„ ๋•Œ ์ƒ์„ฑ๋˜๋Š” ์„ธ์…˜์˜ ํ—ˆ์šฉ ๊ฐœ์ˆ˜๊ฐ€ ์ดˆ๊ณผ๋˜์—ˆ์„ ๊ฒฝ์šฐ์— ์–ด๋–ป๊ฒŒ ๊ทธ ์„ธ์…˜์„ ๊ณ„์†์ ์œผ๋กœ ์ดˆ๊ณผํ•˜์ง€ ์•Š๊ณ  ์„ธ์…˜์„ ์œ ์ง€ํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์ œ์–ด๋ฅผ ๋งํ•œ๋‹ค. ํ—ˆ์šฉ ๋ธŒ๋ผ์šฐ์ € ๊ฐœ์ˆ˜๊ฐ€ 1๊ฐœ๋ผ๊ณ  ๊ฐ€์ •ํ•  ๊ฒฝ์šฐ์— (์‚ฌ์šฉ์ž 1, 2๋Š” ๋™์ผํ•œ ๊ณ„์ •) 1.์ด์ „ ์‚ฌ์šฉ์ž ์„ธ์…˜ ๋งŒ๋ฃŒํ•˜๋Š” ๋ฐฉ๋ฒ• 2. ํ˜„์žฌ ์‚ฌ์šฉ์ž ์ธ์ฆ ์‹คํŒจ ๋™์‹œ ์„ธ์…˜ ์ œ์–ด API maximumSessions : ์„ค์ •ํ•œ ์ˆ˜๋งŒํผ ์ตœ๋Œ€ ํ—ˆ์šฉ ๊ฐ€๋Šฅ ์„ธ์…˜ ์ˆ˜๋ฅผ ์„ค์ • maxSessionPreventsLogin : true๋กœ ์„ค์ •ํ•˜๋ฉด ๋™์‹œ ๋กœ๊ทธ์ธ ์ฐจ๋‹จํ•จ -> ์œ„์—์„œ 2๋ฒˆ์งธ ๋ฐฉ๋ฒ•, false๋Š” 1๋ฒˆ์งธ ๋ฐฉ๋ฒ• invalidSessionUrl expireUrl ๐Ÿ‘‰ ๋ฐ‘์— ๋‘ ๊ฐœ ๋‹ค ์„ค์ •ํ•˜๋ฉด invalidSessionUrl์ด ์šฐ์„ ์ˆœ์œ„๊ฐ€ ..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) ์ต๋ช…์‚ฌ์šฉ์ž ์ธ์ฆ : AnonymousAuthenticationFilter

isAnonymous() : ๋กœ๊ทธ์ธํ•  ๋•Œ ์‚ฌ์šฉ isAuthenticated() : ๋กœ๊ทธ์•„์›ƒํ•  ๋•Œ ์‚ฌ์šฉ ์Šคํ”„๋ง์—์„œ ์žฌ๊ณตํ•˜๋Š” AnonymousAuthenticaitonFilter๋ฅผ ๋ณด๋ฉด @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (SecurityContextHolder.getContext().getAuthentication() == null) { Authentication authentication = createAuthentication((HttpServletRequest) req); SecurityContext ..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) Remember-Me ์ธ์ฆ

๐ŸŽ€ Remember-Me ์„ธ์…˜์ด ๋งŒ๋ฃŒ๋˜๊ณ  ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ข…๋ฃŒ๋œ ํ›„์—๋„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‚ฌ์šฉ์ž๋ฅผ ๊ธฐ์–ตํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. โž• Remember-Me ์ฟ ํ‚ค์— ๋Œ€ํ•œ http์š”์ฒญ์„ ํ™•์ธํ•œ ํ›„ ํ† ํฐ ๊ธฐ๋ฐ˜ ์ธ์ฆ์„ ์‚ฌ์šฉํ•ด ์œ ํšจ์„ฑ์„ ๊ฒ€์‚ฌํ•˜๊ณ  ํ† ํฐ์ด ๊ฒ€์ฆ๋˜๋ฉด ์‚ฌ์šฉ์ž๋Š” ๋กœ๊ทธ์ธ๋œ๋‹ค. ์‚ฌ์šฉ์ž ๋ผ์ดํ”„ ์‚ฌ์ดํด ์ธ์ฆ ์„ฑ๊ณต (Remember-Me ์ฟ ํ‚ค ์„ค์ •) ์ธ์ฆ ์‹คํŒจ (์ฟ ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋ฉด ์ฟ ํ‚ค ๋ฌดํšจํ™”) ๋กœ๊ทธ์•„์›ƒ (์ฟ ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋ฉด ์ฟ ํ‚ค ๋ฌดํšจํ™”) rememberMeParameter : ๋ฒ„ํŠผ ์ด๋ฆ„์ด๋ž‘ ๋˜‘๊ฐ™์ด ํ•ด์•ผ ๋จ alwaysRemember(true) : ๋กœ๊ทธ์ธํ•  ๋•Œ ๋ฆฌ๋ฉค๋ฒ„ ๋ฏธ ์‚ฌ์šฉ ์•ˆ ํ•ด๋„ ํ™œ์„ฑํ™”๋˜์–ด์žˆ์Œ userDetailsService๋Š” ํ•„์ˆ˜ ํ•ด๋‹น ์„ค์ •์„ ํ•˜๊ณ  ๋‚˜์„œ ์„œ๋ฒ„๋ฅผ ์‹คํ–‰์‹œ์ผœ ๋ณด๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ Remember me on this comput..

Spring

[Spring] Spring Security(์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ) Logout์ฒ˜๋ฆฌ, LogoutFilter

๐ŸŒฑ ์ „์ฒด์ ์ธ ๋กœ๊ทธ์•„์›ƒ ๋กœ์ง ์‹œํ๋ฆฌํ‹ฐ๋ฅผ ํ†ตํ•ด ๋กœ๊ทธ์•„์›ƒ์„ ํ•˜๊ฒŒ ๋˜๋ฉด ์„ธ์…˜ ๋ฌดํšจํ™” ์ธ์ฆ ํ† ํฐ ์‚ญ์ œ ์‚ญ์ œํ•  ์ฟ ํ‚ค ์ •๋ณด๊ฐ€ ์žˆ๋‹ค๋ฉด ์‚ญ์ œ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ํ•ด๋‹น ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋œ๋‹ค. ๋กœ๊ทธ์•„์›ƒ API logout : ๋กœ๊ทธ์•„์›ƒ ๊ธฐ๋Šฅ ํ™œ์„ฑํ™” logoutUrl : ๋กœ๊ทธ์•„์›ƒ url ์ •๋ณด ์ „๋‹ฌ (form ํƒœ๊ทธ์—์„œ url ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ) logoutSuccessUrl : ๋กœ๊ทธ์•„์›ƒ ์„ฑ๊ณตํ•  ๋•Œ ์ด๋™ํ•  url deleteCookies : ์ฟ ํ‚ค๋ฅผ ๋ฐœ๊ธ‰ํ–ˆ์„ ๊ฒฝ์šฐ์— ์‚ญ์ œ๊ฐ€ ํ•„์š”ํ•œ๋ฐ ์ฟ ํ‚ค๋ฅผ ์‚ญ์ œํ•จ remember-me ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” ๋‚˜์ค‘์— ๋กœ๊ทธ์ธํ•  ๋•Œ remember-me ์ธ์ฆ์ด ์žˆ๋Š”๋ฐ ์„œ๋ฒ„์—์„œ ๋งŒ๋“  ์ฟ ํ‚ค๋ฅผ ์‚ญ์ œํ•˜๋Š” ๊ฒƒ logoutSuccessHandler : ๋กœ๊ทธ์•„์›ƒ์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ˆ˜ํ–‰๋˜๊ณ  ํ›„์† ์ž‘์—…์„ ํ•˜๋Š” ํ•ธ๋“ค๋Ÿฌ ๋กœ๊ทธ์•„์›ƒ filter ..

DAHLIA CHOI
'๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (4 Page)