스터디-Spring

[스프링 시큐리티] SessionManagementFilter - 세션관리필터

일태우 2022. 2. 14. 18:33
반응형

https://docs.spring.io/spring-security/site/docs/5.1.5.RELEASE/reference/htmlsingle/#session-mgmt

 

Spring Security Reference

The authenticator is also responsible for retrieving any required user attributes. This is because the permissions on the attributes may depend on the type of authentication being used. For example, if binding as the user, it may be necessary to read them

docs.spring.io

 

1. 세션 변조 방지 설정(Session Fixation 방지)

세션 고정(Session Fixation): 로그인 후 발급받은 Session ID를 탈취당하여 공격자가 해당 Session ID를 통해 정상사용자로 접근하는 행위

SessionManagementFilter는 세션을 고정하는것을 방지하기위한 전략을 관리하는 필터

전략

  • none - 보호 적용 안함
  • newSession - 인증 성공시 새로운 세션 생성 (SpringSecurity 속성만 복사)
  • migrateSession - 인증 성공시 새로운 세션을 생성 (모든 속성을 복사)
  • changeSessionId - 인증 성공시 Session ID 변경 (Servlet 3.1 이상 지원)

2. 유효하지 않은 세션 Redirect

  • InvalidSessionUrl

3. 동시성 제어

  • 이미 세션이 존재할 시에 대한 제어
  • maximumSessions - 유저별 최대 세션 수
  • expiredUrl - session expired 되었을 경우 리다이렉트 할 url

4. 세션 생성 전략 - SessionCreationPolicy

  • IF_REQUIRED - 기본전략, Security가 필요하면 생성
  • NEVER - 생성하지 않지만 기존에 세션이 존재하면 생성
  • STATELESS - 세션을 생성하지 않고 기존것도 사용하지 않음
  • ALWAYS - 항상 세션을 생성
반응형