본문 바로가기

분류 전체보기70

SOP (Same-Origin Policy), CORS (Cross-Origin Resource Sharing) 정리 SOP (Same-Origin Policy) SOP는 웹 보안의 기본 개념으로, 웹 브라우저가 스크립트에서 실행되는 동안 다른 출처(origin)의 리소스에 대한 접근을 제한하는 정책 출처는 프로토콜(http, https 등), 호스트(도메인 이름), 포트 번호의 조합으로 정의됨 SOP는 웹 사이트에서 사용자의 데이터를 보호하기 위해 중요 크로스 사이트 스크립팅(XSS) 공격과 같은 보안 취약점을 방지하기 위해 설계 예를 들어, 한 웹 사이트가 다른 사이트의 쿠키, 로컬 스토리지 등에 접근하는 것을 제한함 CORS (Cross-Origin Resource Sharing) CORS는 웹 애플리케이션이 다른 출처의 리소스에 접근할 수 있도록 허용하는 메커니즘 SOP에 의해 기본적으로 제한된 리소스 공유를 가.. 2024. 2. 28.
Spring Cloud Gateway CustomGlobalExceptionHandler 구현 기본 응답 Gateway에서 예외가 발생하면 기본으로 응답되는 포맷은 다음과 같음 { "timestamp": "2024-02-14T08:43:24.955+00:00", "path": "/first-service/hello-post", "status": 401, "error": "Unauthorized", "requestId": "3cafcce1" } 응답을 커스텀하거나 예외 발생 시 특별한 처리를 하려고 하는 경우, Gateway 필터를 구현하는 것처럼 ExceptionHandler를 구현할 수 있음 GatewayResponseVO Gateway에서 응답을 커스텀하기 위해 먼저 VO를 정의 @Data public class GatewayResponseVO { private int status; priva.. 2024. 2. 14.
Spring Cloud Gateway Filter에서 응답 보내기 Gateway Filter에서 인증 등이 실패했을 때, 에러 코드와 메세지를 응답하려고 하는 경우 @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { // ... 로직 if (error) { // 인증 실패 등의 에러가 발생했을 경우 return sendUnauthorizedResponse(exchange); } // 정상 진행 return chain.filter(exchange); } private Mono sendUnauthorizedResponse(ServerWebExchange exchange) { // Map을 byte array로 변환하기 위해 선언, 다른 유틸 함수를 사용해도 됨 ObjectM.. 2024. 2. 8.
Spring Boot spring-security-oauth2-jose 사용해 JWKS URI로 JWT 검증하기 Dependency 추가 1. Maven org.springframework.security spring-security-oauth2-jose 6.2.1 2. Gradle // https://mvnrepository.com/artifact/org.springframework.security/spring-security-oauth2-jose implementation group: 'org.springframework.security', name: 'spring-security-oauth2-jose', version: '6.2.1' 구현 Spring Cloud Gateway에서 요청을 받았을 때 JWT를 검증하는 필터를 구현 @Slf4j @Component public class AuthorizationHe.. 2024. 2. 8.
Spring Cloud Gateway 구현 정리 버전 정보 > Spring Boot 3.2.2 > OpenJDK 17.0.8 > spring-cloud-starter-gateway 4.1.0 > spring-cloud-starter-netflix-eureka-client 4.1.0 Gradle Dependecies dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-gateway' implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client' } Eureka Client로 등록 @EnableDiscoveryClient @SpringBootApplication public cl.. 2024. 2. 6.
RTSP 웹 스트리밍 오픈소스 프로젝트 - RTSPtoWeb으로 React에서 스트리밍 해보기 프로젝트 정보 Language: Go GitHub: https://github.com/deepch/RTSPtoWeb (MIT License) API Docs: https://github.com/deepch/RTSPtoWeb/blob/master/docs/api.md Docker Image: ghcr.io/deepch/rtsptoweb:latest 주요 기능 RTSP URL을 통해 Stream을 추가하면 HLS 스트리밍 엔드포인트를 통해 클라이언트에서 스트리밍 가능 다중 채널 지원 Admin UI ID/PW, Token 인증 방식 지원 HTTPS 지원 Docker로 서버 띄워보기 $ docker run -d --name rtsp-to-web -p 8083:8083 ghcr.io/deepch/rtsptowe.. 2024. 1. 16.