Spring Security6 - Authentication(인증)
·
Spring/Spring Security
1. 인증 관련 주요 클래스와 인터페이스 및 동작원리 Authentication: 인증 요청과 인증된 주체를 나타내는 인터페이스이다. AuthenticationManager: 실제로 인증을 처리하는 인터페이스이다. UserDetailsService: 사용자의 세부 정보를 로드하는 방법을 정의한다. PasswordEncoder: 비밀번호의 암호화 또는 해싱을 처리한다. Spring Security 6의 주요 인증 방식(Basic Authentication, Form-Based Authentication, OAuth2, JWT)은 모두 AuthenticationManager를 사용한다. AuthenticationManager는 UserDetailsService를 호출하여 사용자 정보를 로드하고, Authen..
Spring Security와 CORS: 크로스 도메인 요청 처리 기법 알아보기
·
Spring/Spring Security
웹 애플리케이션을 개발하면서 보안과 리소스 공유는 중요한 고려사항이다. 이번에는 Spring Security와 CORS(Cross-Origin Resource Sharing)에 대해서 자세히 알아보자 1. 크로스 도메인(Cross-Domain) 이해하기 1-1. 크로스 도메인 정의: 크로스 도메인은 한 도메인에서 실행되는 웹 페이지가 다른 도메인의 리소스에 접근할 때 발생하는 상황을 의미한다. 예시: http://domain-a.com에서 로딩된 웹 페이지가 http://domain-b.com의 이미지나 API에 접근하는 것이다. domain-a.com: 여기서 로딩된 웹 페이지가 다른 도메인의 리소스에 접근하려고 한다. domain-b.com: 이 도메인은 이미지나 API와 같은 리소스를 제공한다. A..
Spring Security 6 이해하기: 동작 원리와 보안 기능 탐구
·
Spring/Spring Security
스프링 시큐리티가 어떻게 동작하는지 궁금해서 알아봤다. 1. 최상위 필터 인터페이스인 SecurityFilterChain 확인 package org.springframework.security.web; import java.util.List; import jakarta.servlet.Filter; import jakarta.servlet.http.HttpServletRequest; /** * Defines a filter chain which is capable of being matched against an * {@code HttpServletRequest}. in order to decide whether it applies to that request. * * Used to configure a ..
Spring Boot 3 & Security 6 시리즈: JWT Util 클래스 작성 (7편)
·
Spring/Spring Security
JWT 유틸리티 클래스 작성하기 1. JWT - Util 클래스 작성하기 이 코드는 JWT(JSON Web Token)를 생성하고 검증하는 데 사용되는 TokenUtils 클래스에 대한 것이다. 클래스는 여러 메서드를 포함하고 있으며, JWT의 생성, 유효성 검증 및 관련 정보 추출과 같은 다양한 기능을 수행한다. @Slf4j @Component public class TokenUtils { private static final String jwtSecretKey = "thisIsASecretKeyUsedForJwtTokenGenerationAndItIsLongEnoughToMeetTheRequirementOf256Bits"; // jwtSecretKey를 바이트 배열로 변환하고, 이를 사용하여 HMAC..