๐ Spring security 6
โ๏ธ ConcurrentSessionFilter
- ๋์์ ์์ ๋ํ ์ฒ๋ฆฌ(์ ํ)๋ฅผ ์ํํ๋ค.
- ๋ง๋ฃ๋ ํ ํฐ์ด ๋ค์ด์ค์ง ๋ชปํ๋๋ก ์ ์ดํ๋ค.
โ๏ธ SessionManagementFilter
- SessionAuthenticationStrategy ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํด๋์ค ์ ์ํ๋ค.
- onAuthentication ๊ตฌํ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ค.
์ธ์ฆ์ด ๋ฐ์ํ ๊ฒฝ์ฐ ์ธ์ ์ ์ ๋ต์ ๊ฒฐ์ ํ๋ค.
- onAuthentication ๊ตฌํ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ค.
โ๏ธ ์คํ๋ง์ด ์ง์ํ๋ Authentication strategy filter
- ์ธ์ ๊ณ ์ ์ ์ฑ
- ๋์์ ์ ์ ์ด
โ๏ธ ConcurrentSessionControlAuthenticationStrategy
- ์ธ์ ์ ๋ํ ๋์์ ์ ๋ฐ์์ ์ค์ ๋ ํ๊ณ๊ฐ์ ๋์์ ๋ ๊ธฐ์กด ์ธ์ ์ ๋ง๋ฃ์ํฌ ๊ฒ์ธ์ง, ์๋ก์ด ์ธ์ ์ ๊ฑฐ๋ถํ ๊ฒ์ธ์ง ๊ฒฐ์ ํ๋ค.
http.sessionManagement(
sm -> // allowedSessions
sm.maximumSession(1) // ๋์ผ username ์ธ์
๋์์ ์ ์ ์ค์
.maxSessionPreventsLogin(false) // ๊ธฐ์กด์ธ์
๋ง๋ฃ (default)
.expiredUrl("/session-expired") // ๋ง๋ฃ๋ ์ธ์
redirect
)
โ๏ธ SessionRegistry
- sessionInformation, principals์ ๊ฐ์ง๋ค.
- sessionInformation
- Map<SessionId, SessionInformation>
- principal, sessionId, expired
- SessionRegistry์ principals์์ ํ์ฌ principal๋ก sessionId๋ฅผ ์ถ์ถํ๋ค.
์ถ์ถ๋ sessionId๋ก sessionInformation ์กฐํ ๊ฐ๋ฅํ๋ค.
โ๏ธ Bean ๋ฑ๋ก
@Bean
SessionRegistry sessionRegistry() {
SessionRegistryImpl registry = new SessionRegistryImpl();
return registry;
}
โ๏ธ ์ธ์
ID ๊ณ ์ Session-fixation
http.
sessionManagement(
sm -> sm.sessionFixation(seessionFixationConfigurer.none())
)
sessionFixationConfigurer.changeSessionId() (default)
- ๋ก๊ทธ์ธํ ๋๋ง๋ค ์ธ์ ID๋ฅผ ๋ณ๊ฒฝํ๋ค.
- session-fixation attack ๋ฐฉ์งํ๋ค.
sessionFixationConfigurer.none()
- ๋ก๊ทธ์ธํ ๋๋ง๋ค ์ธ์ ID๋ฅผ ๋ณ๊ฒฝํ์ง ์๋๋ค.
- ๋ก๊ทธ์์ ํ ์ฌ๋ก๊ทธ์ธ ํด๋ ์ธ์ ID๊ฐ ๊ทธ๋๋ก์ด๋ค. (๋ณ๊ฒฝ โ)
โ๏ธ ์ธ์ ์์ฑ ์ ์ฑ
http.
sessionMangement
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
โ๏ธ SessionCreationPolicy
- ALWAYS : ํ์ฌ ์ธ์ ์ด ์๋ค๋ฉด ํญ์ ์์ฑํ๋ค. (์ฌ์ฉ)
- IF_REQUIRED : ์ธ์ ์ด ํ์ํ ๊ฒฝ์ฐ ์์ฑํ๋ค.
- NEVER : ํ์ฌ ํํฐ ๋ด์์๋ ์ธ์ ์์ฑํ์ง ์๋๋. โ
- STATELESS : ์ธ์ ์ ์ฌ์ฉํ์ง ์๋๋ค. โ
๐ ์๊ฐ์ธ์ฆ

ํจ์คํธ์บ ํผ์ค [์ง์ฅ์ธ ์ค๋ฌด๊ต์ก]
ํ๋ก๊ทธ๋๋ฐ, ์์ํธ์ง, UX/UI, ๋ง์ผํ , ๋ฐ์ดํฐ ๋ถ์, ์์ ๊ฐ์, The RED, ๊ตญ๋น์ง์, ๊ธฐ์ ๊ต์ก, ์๋น์ค ์ ๊ณต.
fastcampus.co.kr
๋ณธ ํฌ์คํ ์ ํจ์คํธ์บ ํผ์ค ํ๊ธ ์ฑ๋ฆฐ์ง ์ฐธ์ฌ๋ฅผ ์ํด ์์ฑ๋์์ต๋๋ค.
'Spring Security' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| ํจ์คํธ์บ ํผ์ค ์ฑ๋ฆฐ์ง 18์ผ์ฐจ - Spring Security 7 (0) | 2021.09.23 |
|---|---|
| ํจ์คํธ์บ ํผ์ค ์ฑ๋ฆฐ์ง 16์ผ์ฐจ - Spring Security 5 (0) | 2021.09.21 |
| ํจ์คํธ์บ ํผ์ค ์ฑ๋ฆฐ์ง 15์ผ์ฐจ - Spring Security 4 (0) | 2021.09.20 |
| ํจ์คํธ์บ ํผ์ค ์ฑ๋ฆฐ์ง 14์ผ์ฐจ - Spring Security 3 (0) | 2021.09.19 |
| ํจ์คํธ์บ ํผ์ค ์ฑ๋ฆฐ์ง 13์ผ์ฐจ - Spring Security 2 (0) | 2021.09.18 |