첫날
- spring-security 의존성만 추가해도 보안에 관한 여러빈 이 추가되고
- 기본적인 보안이 됨?
SecuriyBuilder

- Security Builder 는 SecurityConfigurer 포함함 .
- 실제 초기화 작업은 ?
- build() 메서드 실행 -> init() & configure() 실행 -> 초기화설정

대략적인 그림

상세한 그림
-
WebSecurity / HttpSecurity
-
두개의 클래스에는 apply라는 메소드가 있음.!
-
Security Buildeer클래스가 설정 클래스를 실행시킴 어떤 SeurityConfigurer 설정클래스를 실행시킴;
-
어떤 설정 클래스를 실행시킬까? apply 에 전달하면 초기화 대상 적용
- apply() 초기작업에 관여할 적용할 클래스를 찾음.
-
apply() 적용후 build()메서드 호출.
-
여러개의 내부적인 메소드가 순서대로 호출됨. 그 과정에서
-
init , configure 실행되면서 초기화 작업이 실행됨
-
Filter 도 만들고 .. 인증 인가의 필요한 필터와 객체를 생성 위 두개에 메서드에서 만들어 짐.
- 이런 Init / configure 작업 실행 후
- 최종적으로 WebSecurity 가 최종 반환하는건
- FilterCainProxy / SecurityFilterChain 생성
- 전자가 후자에 값을 가지고 있음, 둘은 참조 관계.
- 사용자 요청처리시 후자가 가지고있는 여러개의 필터를 전자가 참조함


위 소스코드 위치는 WebSecurityConfiguration
- 설정 클래스 를 가져와서 apply 메서드를 실행시킴.
- apply 해당 시큐리티 설정 클래스를 초기화 관련 일을 실행시키겠다.
- 다음은 HttpSecurityConfiguration

- 설정 클래스에서 여러개의 HttpSecurity 갯수만큼 빈 생성된다
- csrf 등 api 들은 각각의 시큐리티 설정클래스 구현체를 생성하고
- 구현체 안에 init , confiure 메서드 실행

- csrf 설정 정클래스를 만들어서 apply해서 이 설정클래스를 초기화 과정 때 진행 하도록 적용하겠다?

이렇게 추가.. 개념이 어렵긴하다.

- 이렇게 보면 우리도 custom confiure을 만들어서 넣어서 사용 가능함.


-
이런 설정 클래스들이 적용 되도록 build 됨
-
init() , configure() 여기서 실행

-
위에 13개 설정클래스를 init() 메서드 실행

-
마찬가지.
custom 설정

-
원래 인증인가 처리를 이렇게 했음 과거형


- 이런식으로 커스텀으로 설정만들수 있따..
- 한번 더들어야될듯 아직 머리에..
요약
WebSecurity와 HttpSecurity: 스프링 시큐리티의 핵심 설정 클래스
- WebSecurity는 전체적인 보안 설정에 관련된 클래스
- HttpSecurity는 HTTP 요청에 따른 보안 설정을 하는 클래스
- apply 메서드: WebSecurity나 HttpSecurity에 특정 SecurityConfigurer를 적용하는 메서드다
- SecurityBuilder는 보안 구성을 빌드하는 인터페이스입니다.
- SecurityConfigurer는 보안 구성을 초기화하고 설정하는 인터페이스입니다.
- init와 configure 메서드: SecurityConfigurer에 정의된 메서드로써, init은 초기화 작업을, configure는 설정 작업을 의미합니다. 이들 메서드는 apply를 통해 적용된 SecurityConfigurer들에 대해 호출되어 실행됩니다.
FilterChainProxy와 SecurityFilterChain:
스프링 시큐리티는 여러 보안 관련 필터를 관리하는데, 이 필터들은 SecurityFilterChain에 의해 관리됩니다.
FilterChainProxy는 이러한 SecurityFilterChain을 참조하여, 실제로 사용자의 HTTP 요청이 오면 해당 요청에 따라 적절한 필터 체인을 실행합니다.
좋은 글 감사합니다. 자주 방문할게요 :)