minlog
article thumbnail
[ Security ] 01. 시큐리티 사용하기 - 설정 파일
BackEnd/Security · JPA 2023. 5. 3. 20:05

시큐리티 설정 파일 시큐리티와 관련된 모든 설정들을 관리하는 config 클래스 이다. 스프링 부트 버전 2.7.0 이전에는 ' WebSecurityConfigurerAdapter ' 를 상속( * 페이지 이동 )받아서 사용해야하며, 이후 부터는 사용되지 않으므로 주의 해야한다. 📑SecurityConfig.java package com.example.springsecurity.config; import lombok.extern.log4j.Log4j2; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.configuration.WebSecuri..

article thumbnail
[ JPA ] 동적 쿼리 처리를 해주는 Querydsl 사용해보기
BackEnd/Security · JPA 2023. 4. 16. 00:15

Querydsl JPA 기본 쿼리 메서드의 기능과 @Query 어노테이션만으로 어려운 복잡한 검색 조건을 동적으로 쿼리를 생성해서 처리할 수 있는 기술이다. Querydsl 사용해보기 1. 빌드 추가 라이브러리를 사용하기 위해서 build.gradle 파일에 내용을 추가해주어야 한다. 📑 build.gradle // 1. querydsl 추가 buildscript { ext { queryDslVersion = "5.0.0" } } plugins { id 'org.springframework.boot' version '2.7.10' id 'io.spring.dependency-management' version '1.0.15.RELEASE' //2. querydsl 추가 id "com.ewerk.gradl..

article thumbnail
[ Security ] 시큐리티 - 로그인
BackEnd/Security · JPA 2023. 4. 4. 14:52

Security 로그인 스프링 프레임워크에서 로그인을 한다는 것은 authenticated 가 true인 Authentication 객체를 SecurityContext 에 갖고 있는 상태를 말합니다. 단 Authentication이 AnonymousAuthenticationToken ( 다른 사용자 )만 아니면 됩니다. Authentication (인증)의 기본 구조 인증 토큰 (Authentication)을 제공하는 필터들 UsernamePasswordAuthenticationFilter 폼 로그인 (아이디/패스워드 로그) RememberMeAuthenticationFilter 자동로그인이 선택 되어있다면, 쿠키 로그인 AnonymousAuthenticationFilter 로그인 인증이 되어있지 않았다..

article thumbnail
[ JPA ] Embedded - 재활용 가능한 Entity
BackEnd/Security · JPA 2023. 4. 2. 13:06

Embeddable 반복된 코드는 Embedded JAVA클래스로 따로 생성 해준다. JPA 테이블 생성시 Entity 객체의 필드로 포함이 되는 것을 확인 할 수 있다. 근로기간, 전화번호, 주소 같은 내용들을 Embeddable로 사용할 수 있다. ex) 회원정보 테이블과 회원정보 히스토리 테이블 1. 공통 된 코드 ( Embeddable) 객체 생성. @Embeddable - entity 내부에 선언 할수 있게됨 📑 Address.java @Data @AllArgsConstructor @NoArgsConstructorE @Embeddable public class Address{ private String city; //시 private String district; //구 @Column(name=..

article thumbnail
[ JPA ] @Query ( 쿼리 커스텀 ) - Native Query
BackEnd/Security · JPA 2023. 3. 31. 16:22

@Query 쿼리 메서드의 커스텀 버전이라고 생각할 수 있다. 보통 쿼리 메서드 만으로 일반적인 기능들을 처리할 수 있다. 하지만 다음의 두가지 케이스에서 필요하다. 쿼리메서드의 문제점을 보완해줄 수 있다. 1. 쿼리메서드의 가독성 문제 1) 쿼리메서드의 이름이 길어지는 경우 ex) 카테고리 = null , 이름 =파라미터와 같은것 ,created_at 파라미터 값보다 크거나 같은것, updated_at 파라미터 값보다 크거나 같은 것을 조회 List findByCateqoryIsNullAndNameEqualsAndCreatedAtGreaterThanEqual(String name, LocalDateTime createAt,LocalDateTime updateAt); - 수정 된 소스 : JPQL 을 사..