전체 글
24. 프로필 수정 폼
프로필 수정 뷰 컨트롤러 Bio, Link, Occupation, Location 정보만 입력받아서 Account 정보를 수정한다. 실습 시작 커밋: https://github.com/devjun63/whiteship-studyolle/commit/80556822d7310a98de49a3edae0db51d734cdf64 완료 커밋: https://github.com/devjun63/whiteship-studyolle/commit/aa47902ed3f52fad9b7d31073e84f1ed5770d50d 24. 프로필 수정 폼 · devjun63/whiteship-studyolle@aa47902 Permalink This commit does not belong to any branch on this rep..
23. Open EntityManager (또는 Session) In View 필터
JPA EntityManager(영속성 컨텍스트)를 요청을 처리하는 전체 프로세스에 바인딩 시켜주는 필터. 뷰를 랜더링 할때까지 영속성 컨텍스트를 유지하기 때문에 필요한 데이터를 랜더링 하는 시점에 추가로 읽어올 수 있다. (지연 로딩, Lazy Loading) 엔티티 객체 변경은 반드시 트랜잭션 안에서 할 것 영속성 컨텍스트 (Jpa EntityManager, Hibernate session) 현재 버그 컨트롤러에서 데이터를 변경했다. 왜 DB에 반영되지 않았을까? 서비스에서 트랜잭션 관리하는 경우 리파지토리 직접 사용 경우 스터디올래의 선택 데이터 변경은 서비스 계층으로 위임해서 트랜잭션안에서 처리한다. 데이터 조회는 리파지토리 또는 서비스를 사용한다. 실습 시작 커밋: https://github.c..
22. 프로필 뷰
정보가 없는 프로필 뷰 정보가 있는 프로필 뷰 정보의 유/무 여부에 따라 보여줄 메시지가 다르다. 현재 유저가 프로필을 수정할 수 있는 권한이 있는지 판단해야 한다. 부트스트랩 ListGroup Grid 실습 시작 커밋: https://github.com/devjun63/whiteship-studyolle/commit/fb9abd45d3eef033fd4ab80d7f95c54391541140 완료 커밋:https://github.com/devjun63/whiteship-studyolle/commit/1ab35c3a6be93fb342de8092a3690aa0cbce666c 22. 프로필 뷰 만들기 · devjun63/whiteship-studyolle@1ab35c3 Permalink This commit d..
21. 로그인 기억하기 (RememberMe)
세션이 만료 되더라도 로그인을 유지하고 싶을 때 사용하는 방법 쿠키에 인증 정보를 남겨두고 세션이 만료 됐을 때에는 쿠키에 남아있는 정보로 인증한다. application.properties server.servlet.session.timeout=30m // session 유지 기본 30분으로 설정되어있음 -> 시간 늘리면 메모리 부담 ↑ 해시 기반의 쿠키 Username Password 만료 기간 Key (애플리케이션 마다 다른 값을 줘야 한다.) 치명적인 단점, 쿠키를 다른 사람이 가져가면... 그 계정은 탈취당한 것과 같다. 조금 더 안전한 방법은? 쿠키안에 랜덤한 문자열(토큰)을 만들어 같이 저장하고 매번 인증할 때마다 바꾼다. Username, 토큰 문제는, 이 방법도 취약하다. 쿠키를 탈취 당..
20. 로그인 / 로그아웃 테스트
테스트 요점 정리 폼 서브밋 요청 (post)은 반드시 .with(csrf())를 추가할 것. .andExpect(authenticated()) 또는 .andExpect(unauthenticated())로 인증 여부를 확인할 수 있다. 리다이렉트 응답은 .andExpect(status().is3xxRedirection()) 로 확인한다. 리다이렉트 URL은 .andExpect(redirectedUrl()) 로 확인할 수 있다. JUnit 5의 @BeforeEach와 @AfterEach. 임의로 로그인 된 사용자가 필요한 경우에는 @WithMockUser. spring security -> form 그냥 보내면 안됨 why? csrf라는 protection활성화 token param값을 다르게 주고 싶다면..
예제로 배우는 스프링 프레임워크 입문 - 스프링 PSA
PSA (Potable Service Abstraction) 소개 환경의 변화와 관계없이 일관된 방식의 (코드 유지) 기술로의 접근 환경을 제공하려는 추상화 구조 Service Abstraction https://en.wikipedia.org/wiki/Service_abstraction Service abstraction - Wikipedia Service abstraction is a design principle that is applied within the service-orientation design paradigm so that the information published in a service contract is limited to what is required to effectivel..