분류 전체보기 1341

ch01. Users Microservice - AuthenticationFilter 추가

RequestLogin VO 생성 사용자가 로그인한 값을 저장하기 위한 VO 추가할 Filter 작성 UsernamePasswordAuthenticationFilter를 상속받은 AuthenticationFilter를 구현한다. attemptAuthentication 메소드와 successfulAuthentication 메서드를 재정의 한다 attemptAuthentication 메소드에서 UsernamePasswordAuthenticationToken으로 email, password, 권한 정보를 주어 토큰으로 변경한 뒤, 참조하고 있던 Manager에게 해당 토큰을 주어 인증하도록 한다. successfulAuthentication 메소드에서 성공 후 처리 작성할 것이다.(토큰 만료시간 등등을 적어줄..

ch04. Orders Microservice - 기능 구현

ModelMapper 추가 Application.yml server: port: 0 spring: application: name: order-service h2: console: enabled: true settings: web-allow-others: true path: /h2-console jpa: hibernate: ddl-auto: update datasource: driver-class-name: org.h2.Driver url: jdbc:h2:mem:testdb username: sa eureka: instance: instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}} client: r..

ch03. Catalogs Microservice - 기능 구현

ModelMapper 추가 application.yml server: port: 0 spring: application: name: catalog-service h2: console: enabled: true settings: web-allow-others: true path: /h2-console jpa: defer-datasource-initialization: true hibernate: ddl-auto: create-drop show-sql: true generate: true datasource: driver-class-name: org.h2.Driver url: jdbc:h2:mem:testdb username: sa eureka: instance: instance-id: ${spring.ap..

Users Microservice - Spring Security 연동

SpringSecurity 추가 인증 + 인가(Authentication + Authorization) 의존성 추가(Dependency 추가) SpringSecurity를 사용할 것이기 때문에 SpringSecurity 라이브러리를 추가한다. WebSecurity 추가 (SecurityConfig 파일 추가) WebSecurityConfigurerAdapter를 오버라이드 하여 구현 csrf 사용 X /users/** 는 모두 통과(권한 체크 X) H2 console을 접속을 하기 위해서는 frameOption을 켜야 된다. 안 킬 시 H2 Console 접속 시 권한이 없어 프레임이 보이지 않는 문제가 있다. BCryptPasswordEncoder(암호화를 위해 사용) 패스워드 해싱을 위해 Bcrypt..

Users Microservice - 사용자 추가

의존성 추가(Dependency 추가) class 간의 변화를 쉽게 도와주는 modelmapper dependency를 추가한다. ORM을 사용하기 위한 SpringDataJpa dependency를 추가한다. Controller 메서드 추가, UserService 생성자 주입 User등록 Controller ModelMapper를 사용하여 UserRequest를 UserDto로 변환하였다 Validation이 적용이 된 Request를 받을 수 있다. UserDto 클래스를 만들어 반환될 객체를 생성한다. UserServiceImpl (UserService 구현체) 생성자로 Repository를 주입받아 저장한다. UserDto -> UserEntity로 modelMapper를 사용하여 변환한다 Use..