Skip to content

Spring Security ‐ Integration

woo jin edited this page Feb 16, 2026 · 3 revisions

Servlet API 통합

  • Spring Security는 다양한 프레임워크 및 API와의 통합을 제공하고 있으며, Servlet 3과 Spring MVC와 통합을 통해 편리한 기능들을 사용할 수 있다.
  • 인증 관련 기능들을 필터가 아닌 서블릿 영역에서도 처리할 수 있다.

SecurityContextHolderAwareRequestFilter

  • HTTP 요청이 처리될 때 HttpServletRequest에 보안 관련 메서드를 추가적으로 제공하는 래퍼(Wrapper) 클래스를 적용한다.
  • 이를 통해 개발자는 서블릿 API의 보안 메서드를 사용하여 인증, 로그인, 로그아웃 등의 작업을 수행할 수 있다.

HttpServlet3RequestFactory

  • Servlet 3 API와의 통합을 위해 Servlet3SecurityContextHolderAwareRequestWrapper 객체를 생성한다.

Servlet3SecurityContextHolderAwareRequestWrapper

  • HttpServletRequest의 래퍼 클래스로서 Servlet 3.0 기능을 지원하면서 동시에 SecurityContextHolder와의 통합을 제공한다.
  • 이 래퍼를 사용함으로써 SecurityContext에 접근할 수 있고 Servlet 3.0 비동기 처리와 같은 기능을 사용하는 동안 보안 컨텍스트를 올바르게 관리할 수 있다.
스크린샷 2025-08-17 오후 4 27 12

@AuthenticationPrincipal

  • Spring Security는 Spring MVC 인수에 대한 현재 Authentication.getPrincipal()을 자동으로 해결할 수 있는 AuthenticationPrincipalArgumentResolver를 제공한다.
  • Spring MVC에서 @AuthenticationPrincipal을 메서드 인수에 선언하게 되면 Spring Security와 독립적으로 사용 가능하다.
스크린샷 2025-08-17 오후 4 32 14

@AuthenticationPrincipal(expression="표현식")

  • principal 객체 내부에서 특정 필드나 메서드에 접근하고자 할 때 사용할 수 있으며 사용자 세부 정보가 principal 내부의 중첩된 객체에 있는 경우 유용하다.
스크린샷 2025-08-17 오후 4 34 01 스크린샷 2025-08-17 오후 4 34 40
  • @AuthenticationPrincipal을 자체 주석으로 메타 주석화하여 Spring Security에 대한 종속성을 제거할 수도 있다.

WebAsyncManagerIntegrationFilter

  • Spring Security는 Spring MVC Controller에서 Callable을 실행하는 비동기 쓰레드에 SecurityContext를 자동으로 설정하도록 지원한다.
  • Spring Security는 WebAsyncManager와 통합해 SecurityContextHolder에서 사용 가능한 SecurityContext를 Callable에서 접근가능하도록 지원해준다.
  • WebAsyncManagerIntegrationFilter
    • SecurityContextWebAsyncManger 사이의 통합을 제공하며 WebAsyncManager를 생성하고 SecurityContextCallableProcessingInterceptorWebAsyncManager에 등록한다.
  • WebAsyncManager
    • 쓰레드 풀의 비동기 쓰레드를 생성하고 Callable를 받아 실행시키는 주체로서 등록된 SecurityContextCallableProcessingInterceptor를 통해 현재 쓰레드가 보유하고 있는 SecurityContext 객체를 비동기 쓰레드의 Local Thread에 저장시킨다.

📖 Java

📖 Kotlin

📖 Coroutine

📖 Spring

📖 Spring Security

📖 Spring Batch

📖 Reactive Programming

📖 Database

📖 MySQL

📖 Redis

📖 JPA

📖 QueryDsl

📖 MSA

📖 Kafka

📖 Apache Flink

  • [Apache Flink - Apache Flink Architecture]
  • [Apache Flink - Stream Processing]
  • [Apache Flink - Data Stream API & Window]
  • [Apache Flink - State Management]

📖 HTTP

📖 AWS

📖 Docker

📖 Kubernetes

📖 CI/CD

📖 Nginx

📖 Monitoring🥈

  • [Monitoring - Log Concept]
  • [Monitoring - Log Level & Filter]
  • [Monitoring - Logback]
  • [Monitoring - Log Collection with ELK Stack]
  • [Monitoring - Log Monitoring with Kibana]
  • [Monitoring - Building a Monitoring System with Spring Boot Actuator]
  • [Monitoring - Server Monitoring with Prometheus and Grafana with Discord Alerts]

📖 Test

📖 Effective Java 3/E

📖 Kotlin Academy - Effective Kotlin

📖 Kotlin Academy - 핵심편

📖 스프링으로 시작하는 리액티브 프로그래밍

📖 가상 면접 사례로 배우는 대규모 시스템 설계 기초 1

📖 가상 면접 사례로 배우는 대규모 시스템 설계 기초 2

📖 Clean Code

📖 리팩토링 2판

📖 주니어 백엔드 개발자가 반드시 알아야 할 실무 지식

📖 GraphQL

Clone this wiki locally