본문 바로가기

분류 전체보기

(122)
[Spring Boot] Security6 세션 정보 및 CORS 설정 (6) https://docs.spring.io/spring-security/reference/servlet/integrations/cors.html CORS :: Spring SecuritySpring Framework provides first class support for CORS. CORS must be processed before Spring Security, because the pre-flight request does not contain any cookies (that is, the JSESSIONID). If the request does not contain any cookies and Spring Security isdocs.spring.io  세션 정보 확인@GetMapping("/t..
[Spring Boot] Security6 JWT 검증 필터 (5) package com.example.loans_domain.auth.jwt;import com.example.loans_domain.auth.entity.CustomUserDetails;import com.example.loans_domain.auth.entity.UserEntity;import com.example.loans_domain.auth.entity.constant.Role;import jakarta.servlet.FilterChain;import jakarta.servlet.ServletException;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import lomb..
[Spring Boot] Security6 로그인 성공 JWT 발급 (4) LoginFilterpackage com.example.loans_domain.auth.jwt;import com.example.loans_domain.auth.entity.CustomUserDetails;import jakarta.servlet.FilterChain;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import lombok.RequiredArgsConstructor;import org.springframework.security.authentication.AuthenticationManager;import org.springframework.security.authen..
[Spring Boot] Security6 JWT 발급 (3) https://jwt.io/ JWT.IOJSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.jwt.io https://softwaresaramdle.tistory.com/48 [Spring Boot] Security6 토큰 기반 인증에 대한 설명토큰의 개요토큰은 사용자가 로그인할 때 생성되는 고유한 문자열입니다.이 토큰은 UUID 형식일 수도 있고, JSON Web Token (JWT) 형식일 수도 있습니다.사용자는 로그인 후 이 토큰을 받아서, 이후의softwaresaramdle.tistory.com https://softwaresaramdle.ti..
[Spring Boot] Security6 로그인 필터 구현 및 DB 로그인 검증(2) https://docs.spring.io/spring-security/reference/servlet/architecture.html Architecture :: Spring SecurityThe Security Filters are inserted into the FilterChainProxy with the SecurityFilterChain API. Those filters can be used for a number of different purposes, like authentication, authorization, exploit protection, and more. The filters are executed in a specdocs.spring.io 로직 흐름더보기사용자  |  vPOST..
[Spring Boot] Security6 회원가입 (1) 로직 흐름더보기사용자   |  vPOST /join (JoinRegisterDTO)  |  vJoinController  |  vjoinService.join(joinDTO)  |  vuserRepository.existsByUserEmail(joinDTO.getUser_email())  |  v(이메일 중복 확인)  |  v비밀번호 암호화  |  vJoinRegisterDTO에 암호화된 비밀번호 설정  |  vUserEntity.createUserEntity(joinDTO)  |  vUserEntity 객체 생성  |  vuserRepository.save(user)  |  v데이터베이스에 UserEntity 저장 1. JoinRegisterDTOJoinRegisterDTO 클래스는 회원가입 시 사용자..
[Spring Boot] JPA Auditing, BaseEntity 생성일, 수정일 자동화 데이터의 생성시간, 수정시간, 생성한 사람, 마지막으로 수정한 사람을 저장해야 할 때가 있습니다.생성 시간 수정 시간 저장을 자동화하고 BaseEntity로 만들어서, 필요한 엔티티들은 모두 BaseEntity를 상속받는다. package com.example.loans_domain.auth.entity;import jakarta.persistence.Column;import jakarta.persistence.EntityListeners;import jakarta.persistence.MappedSuperclass;import lombok.Getter;import org.springframework.data.annotation.CreatedBy;import org.springframework.data...
[Spring Boot] Security6 JWTTokenValidatorFilter package com.booktory.booktoryserver.config;import com.booktory.booktoryserver.config.constants.SecurityConstants;import io.jsonwebtoken.Claims;import io.jsonwebtoken.Jwts;import io.jsonwebtoken.security.Keys;import jakarta.servlet.FilterChain;import jakarta.servlet.ServletException;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import org.springfra..
[Spring Boot] Security6 JWTTokenGeneratorFilter Spring Security와 JWT(JSON Web Token)를 사용하여 인증된 사용자를 위한 JWT 토큰을 생성하는 필터입니다. 이 필터는 OncePerRequestFilter를 확장하여 한 요청당 한 번만 실행되도록 설계되었습니다.package com.booktory.booktoryserver.config;import com.booktory.booktoryserver.config.constants.SecurityConstants;import io.jsonwebtoken.Jwts;import io.jsonwebtoken.security.Keys;import jakarta.servlet.FilterChain;import jakarta.servlet.ServletException;import jakar..
[Spring Boot] Security6 Access-Control-Expose-Headers CORS 설정이 되어 있더라도 Access-Control-Expose-Headers 설정 없이 특정 응답 헤더에 접근하는 것은 제한됩니다. Access-Control-Expose-Headers를 설정하지 않으면, 브라우저는 보안상의 이유로 응답 헤더 중 기본적으로 노출된 헤더만 접근할 수 있도록 합니다. 즉, Authorization 헤더는 기본적으로 노출되지 않으므로, setExposedHeaders를 통해 노출시키지 않으면 클라이언트에서 접근할 수 없습니다. 서버 측 코드:@Overrideprotected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Aut..