본문 바로가기

Spring10

Spring Data MongoDB Document (Proxy)객체 저장 후 로드 시 에러 발생 session에 document를 레디스를 통해 저장했다가 다른 WAS에서 세션을 로드시 cglib proxy 객체 때문에 다시 로드하지 못하는 이슈를 해결하기 위해 찾아보면서 방법들을 정리해본다. 1. 데이터를 전달해야될경우 시리얼라이즈 하기 위해 DTO에 매핑한다. 2. dbref 어노테이션으로 lazy loading을 했을 경우 해당 필드는 LazyLoadingProxy에 캐스팅할수 있다. //target db ref field if (object instanceof LazyLoadingProxy) { LazyLoadingProxy proxy = (LazyLoadingProxy)object; target = proxy.getTarget(); } 3. spring cglib proxy객체를 생성한것이.. 2019. 8. 14.
1) Spring Boot Validation - Annotation 메세지 & Exception 에러 발생시 동작 설명 @Vaild, @NotBlank annotation을 이용한 Server Validation 사용 예제 응답 에러 메세지 @NotNull 예제:) { "timestamp":"2019-06-25T05:34:07.173+0000", "status":400, "error":"Bad Request", "errors":[ { "codes":[ "NotNull.agDto.pe", "NotNull.agype", "NotNull" ], "arguments":[ { "codes":[ " ..." ], "arguments":null, "defaultMessage":"...", "code":"..." } ], "defaultMessage":"반드시 값이 있어야 합니다.", "objectName":"...", "field":.. 2019. 6. 14.
Spring Boot Jwt인증시 static 리소스 CSRF토큰 재발급 문제 세션이 아닌 JWT인증서버를 구축하여 CSRF방지를 포함한 로그인을 개발하는 도중 이슈가 발생된 일이다. 로그인성공하여 인증된 상태로 form으로 post요청을 할 경우 csrf토큰이 불일치 하는경우가 발생 하였다. 페이지를 로딩할때 정직인 리소스들의 요청들이 csrf토큰을 다시 generate하고 있었던 것이다. 디버그로 추척을 해보았더니 SessionManagementFilter에서 sessionAuthenticationStrategy (CompositeSessionAuthenticationStrategy)를 보면 CsrfAuthenticationStrategy를 포함하고 있다는것을 알 수 있다. CsrfAuthenticationStrategy는 onAuthentication메소드에서 토큰여부를 체크.. 2019. 6. 11.
몽고디비 Spring Data Mongodb 설정 (auth 및 replicaSet ) 스프링 설정중 authDB 에 대한 설정을 해주지 않아 계정에 대한 권한 오류가 발생하였다. 'not authorized on 디비 to execute command ...' 다음과 같이 몽고디비 연결 설정을 해주면 된다. spring.data.mongodb.uri: mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB 몽고디비 Replica Set 설정 몽고디비 Security Authentication 설정 (with Replica Set) 2019. 4. 12.