이해할 때까지 설명하는 개발자
close
프로필 배경
프로필 로고

이해할 때까지 설명하는 개발자

  • 전체 (204) N
    • 경험담(經驗) 경험담(輕險) (0)
    • 독서 (64) N
      • 소프트웨어 장인 (0)
      • tidy first (13)
      • extreme programming (23)
      • 객체지향의 사실과 오해 (27) N
    • 회고 (4)
    • 단편 (30)
      • Java (22)
      • js (2)
      • scratch (4)
      • tistory (2)
    • 시리즈 (105)
      • 나 혼자 떠드는 자바 (9)
      • Go (29)
      • Java online live study S01 (15)
      • Kubernetes (15)
      • Spring Security (22)
      • Spring Web MVC (15)
    • Archive (1)
  • portfolio
  • tech-blog
  • linked-in
  • naver-blog
CsrfFilter

CsrfFilter

CsrfFilterCSRF 공격CSRF(Cross-Site Request Forgery)는 사용자의 의지와 무관하게 해커가 사용자의 브라우저를 통해 서버로 특정 요청을 보내도록 하는 공격 방식이다.예를 들어 사용자가 로그인된 상태에서 악성 웹사이트에 방문하면, 해당 사이트가 사용자의 세션을 이용하여 특정 요청을 실행할 수 있다.주로 서버가 session 방식으로 운영 중일 때 사용 된다.session 방식은 브라우저의 쿠키 값을 가지고 서버 측에 요청을 하면, 별다른 인증 절차 없이 요청을 처리하기 때문이다.JWT 토큰을 사용 할 경우 해커가 header 의 JWT 토큰을 삽입하기가 어렵지만, session 방식에서는 데이터 변조 요청만 보내면 된다. CsrfFilter 목적이 필터는 DefaultSec..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 12.
  • textsms
CorsFilter

CorsFilter

CorsFilter들어가며API 서버를 구축할 때 프론트엔드와 백엔드의 오리진이 다르면 CORS 문제가 발생한다.실무에서도 CORS 문제를 해결하기 위해 SecurityFilterChain 에 CorsConfigurationSource 값을 설정하는 것이 중요하다.CorsFilter 자체는 복잡한 로직을 수행하지 않으며, CORS 설정이 더 중요한 개념이다.그래도 CorsFilter 가 어떤 방식으로 동작하는지 알아두는 것이 좋다.CorsFilter 목적이 필터는 DefaultSecurityFilterChain 에 기본적으로 등록되며, 다섯 번째에 위치한다.CORS 정책을 적용하여 브라우저에서 발생하는 CORS 차단 문제를 해결하는 역할을 한다.CorsConfigurationSource 에 설정된 값을 ..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 11.
  • textsms
HeaderWriterFilter

HeaderWriterFilter

HeaderWriterFilterHeaderWriterFilter 목적이 필터는 DefaultSecurityFilterChain 에 기본적으로 등록되며, 네 번째에 위치한다.HTTP 응답 헤더에 보안 관련 헤더를 추가하여 클라이언트를 보호한다.기본적으로 다양한 보안 헤더가 자동으로 추가되며, 이를 통해 XSS, MIME 스니핑, Clickjacking 등의 공격을 방지할 수 있다.커스텀 SecurityFilterChain 을 생성해도 기본적으로 등록되며, 비활성화하려면 아래와 같이 설정할 수 있다.http.headers((headers) ->headers.disable());하지만 보안상의 이유로 비활성화하지 않는 것이 권장된다. 필요에 따라 특정 헤더만 비활성화하는 것이 좋다.HeaderWriterFi..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 10.
  • textsms
SecurityContextHolderFilter

SecurityContextHolderFilter

SecurityContextHolderFilterSecurityContextHolderFilter 목적이 필터는 DefaultSecurityFilterChain 에 기본적으로 등록되며, 세 번째에 위치한다.Security session 방식에서 주로 사용 된다.이전 요청을 통해 인증된 사용자 정보를 현재 요청의 SecurityContextHolder 의 SecurityContext 에 할당한다.현재 요청이 끝나면 SecurityContext 를 초기화하여 다음 요청에서 불필요한 인증 정보를 제거한다.커스텀 SecurityFilterChain 을 생성해도 기본적으로 등록되며, 비활성화하려면 아래와 같이 설정하면 된다.@Beanpublic SecurityFilterChain filterChain(HttpSe..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 9.
  • textsms
WebAsyncManagerIntegrationFilter

WebAsyncManagerIntegrationFilter

WebAsyncManagerIntegrationFilterWebAsyncManagerIntegrationFilter 목적이 필터는 DefaultSecurityFilterChain 에 기본적으로 등록되는 필터이며, 두 번째에 위치한다.비동기 요청이 발생할 경우, 기존의 SecurityContext 를 새로운 비동기 쓰레드에서도 동일하게 유지할 수 있도록 도와준다.기본적으로 SecurityContextHolder 는 ThreadLocal 전략을 사용하여 동일한 쓰레드에서만 SecurityContext 를 공유할 수 있다.하지만 비동기 방식에서는 하나의 작업을 두 개의 쓰레드에서 수행하기 때문에, 기존 SecurityContext 를 유지하는 추가적인 처리가 필요하다.WebAsyncManagerIntegrat..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 8.
  • textsms
DisableEncodeUrlFilter

DisableEncodeUrlFilter

DisableEncodeUrlFilterDisableEncodeUrlFilter 목적이 필터는 DefaultSecurityFilterChain 에 기본적으로 등록되는 필터이며, 가장 첫 번째에 위치한다.DisableEncodeUrlFilter 의 목적은 URL 파라미터에 세션 ID가 포함되어 로그로 유출되는 것을 방지하는 것이다.커스텀 SecurityFilterChain 을 생성하더라도 기본적으로 등록된다.필요하지 않은 경우 아래와 같이 sessionManagement 설정을 disable() 하면 비활성화할 수 있다.http.sessionManagement((manage) -> manage.disable());DisableEncodeUrlFilter 클래스DisableEncodeUrlFilter 는 O..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 7.
  • textsms
GenericFilterBean 과 OncePerRequestFilter

GenericFilterBean 과 OncePerRequestFilter

GenericFilterBean 과 OncePerRequestFilterGenericFilterBean vs OncePerRequestFilterSecurityFilterChain 에 등록된 필터는 GenericFilterBean 기반과 OncePerRequestFilter 기반으로 나뉜다.두 방식의 차이는 "한 번의 클라이언트 요청" 기준에서 동작 방식이 다르다는 점이다.필터 종류실행 방식GenericFilterBean같은 요청에서 여러 번 실행될 수 있음OncePerRequestFilter같은 요청에서 한 번만 실행됨GenericFilterBean 의 동작 방식요청이 같은 필터를 여러 번 통과할 경우, 통과한 횟수만큼 실행된다.즉, 클라이언트의 한 번 요청에 대해 여러 번 필터가 실행될 수 있다.Cu..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 6.
  • textsms
필터 상속과 요청 전파

필터 상속과 요청 전파

필터 상속과 요청 전파SecurityFilterChain 의 필터SecurityFilterChain 에 속한 각각의 필터를 이해하기 전에, 필터의 구조를 먼저 살펴보자.모든 필터는 공통된 부모 필터 클래스를 상속받아 구현되며, 이를 통해 중복 코드 방지 및 역할 분리가 가능하다.필터의 상속Spring Security 의 필터들은 계층적으로 구성되어 있으며, 공통적인 기능을 가진 부모 필터를 상속하여 구현된다.필터는 최상위 Filter 인터페이스를 기반으로 하며, 이를 확장하여 여러 필터가 존재한다.SecurityFilterChain 에서의 필터 계층 구조SecurityFilterChain 에서 필터들은 체인 형태로 연결되며, 각 필터가 특정 보안 로직을 수행한 후 다음 필터로 요청을 전달한다.상속의 이점..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 5.
  • textsms
SecurityContextHolder

SecurityContextHolder

SecurityContextHolderSecurityFilterChain 에서 작업 상태 저장 필요SecurityFilterChain 내부의 각 필터는 시큐리티 관련 작업을 수행한다.모든 필터는 각기 다른 기능을 수행하며, 앞단에서 수행된 작업의 결과를 뒷단 필터에서 확인할 수 있어야 한다.예를 들어, 인가(Authorization) 필터는 요청을 허용할지 결정하기 위해 인증(Authentication) 필터가 설정한 사용자 권한(ROLE) 정보를 확인해야 한다.SecurityContext 와 Authentication 객체SecurityContextHolder 는 현재 요청의 보안 컨텍스트(SecurityContext)를 관리하는 클래스이다.SecurityContext 내부에는 인증(Authentica..

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 4.
  • textsms
SecurityFilterChain 구조

SecurityFilterChain 구조

SecurityFilterChain 구조@EnableWebSecurity 에 debug 모드를 true 로 설정하면, 요청이 통과하는 SecurityFilterChain 의 filter 목록이 출력 된다.Spring Security 디버깅을 활성화하는 옵션으로, 개발 환경에서만 사용해야 한다.debug 모드의 기본값은 false 이다. import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org...

  • format_list_bulleted 시리즈/Spring Security
  • · 2025. 5. 3.
  • textsms
  • navigate_before
  • 1
  • ···
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • ···
  • 21
  • navigate_next
공지사항
  • 블로그 개편 안내: 더 깊이 있는 기술 글은 GitHub 블로그에서 만나보세요
전체 카테고리
  • 전체 (204) N
    • 경험담(經驗) 경험담(輕險) (0)
    • 독서 (64) N
      • 소프트웨어 장인 (0)
      • tidy first (13)
      • extreme programming (23)
      • 객체지향의 사실과 오해 (27) N
    • 회고 (4)
    • 단편 (30)
      • Java (22)
      • js (2)
      • scratch (4)
      • tistory (2)
    • 시리즈 (105)
      • 나 혼자 떠드는 자바 (9)
      • Go (29)
      • Java online live study S01 (15)
      • Kubernetes (15)
      • Spring Security (22)
      • Spring Web MVC (15)
    • Archive (1)
최근 글
인기 글
태그
  • #독서모임
  • #독후감
  • #스프링시큐리티
  • #Spring
  • #spring security
  • #java
  • #객체지향의사실과오해
  • #자바
  • #language
  • #go
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바