apigateway의 application.yml을 보면 get요청에는 authorizationHeaderFilter를 적용시키고 있습니다. authenticFilter는 그저 로그인 요청시 attempthAuthentication메소드와 successfulAthentication메소드를 통해 인증을 처리하고 response헤더에 토큰을 추가하는 역할입니다. 따라서 로그인 요청에만 적용하면 될 것 같은데, 깃허브의 최신코드 버전을 보면 거의 모든 요청에 authenticationFilter를 적용하고 있습니다. 왜 로그인요청이 아닌 다른 요청에다가 AthenticFilter를 적용할까요? apiGateway-service에서 GET요청만 AuthoriztionFilter를 적용하면 되지않나요?? http.authorizeHttpRequests((authz) -> authz .requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/users", "POST")).permitAll() .requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll() // .requestMatchers(new AntPathRequestMatcher("/welcome/**")).permitAll() // .requestMatchers("/**").access(this::hasIpAddress) .requestMatchers("/**").access( new WebExpressionAuthorizationManager("hasIpAddress('127.0.0.1') or hasIpAddress('172.30.1.48')")) .anyRequest().authenticated() )
안녕하세요. 깃허브에서 spring boot 3.2 브랜치통해 코드를 작성했습니다. 그런데 회원가입, 로그인까지 해서 jwt토큰까지는 잘 받아오는데, 그 이후에 /welcome으로 헤더에 토큰으로 추가해서 요청을 보내도 403 forbidden에러가 뜹니다. 코드는 spring boot 3.2 브랜치와 동일합니다.
안녕하세요 로그인시에는 인증이 필요하지가 않는데 자꾸 인증 해주는 AuthorizationHeaderFilter 클래스에서 apply 메소드에서 header 값이 없다고 걸립니다. 그래서 아래와 같이 401 오류로 로그인이 안됩니다. application.yml 파일은 문제없는거 같은데 뭘 더 확인해봐야 할까요,,,? 아래는 Users application.yml 파일입니다.
@Configuration @EnableWebSecurity public class WebSecurity { extends WebSecurityConfigurerAdapter { private UserService userService; private BCryptPasswordEncoder bCryptPasswordEncoder; private Environment env; public WebSecurity(Environment env, UserService userService, BCryptPasswordEncoder bCryptPasswordEncoder) { this.env = env; this.userService = userService; this.bCryptPasswordEncoder = bCryptPasswordEncoder; } 강의에서 보면 @Configuration으로 WebSecurity클래스가 설정되어있기에 userService, bCryptPasswordEncoder, environment 인스턴스가 준비되어 있다고합니다. 따라서 위의 코드와 같이 생성자주입을 하지않는데, 왜 @Configuration으로 설정되어 있으면 @Autowired로 주입을 받지 않아도 되는 걸까요?
안녕하세요. "섹션 16. 애플리케이션 배포 - Docker Container"을 학습하면서 config-service를 Docker로 만들어 실행하면 컨테이너 실행 됐다가 Exit가 되고, "docker logs config-service"로 로그를 보면 아래와 에러가 발생합니다. JDK11 , springboot 2.4.5 버전에 spring-cloud-starter-bootstrap 의존성은 추가 되어 있는 상태입니다. 답변 부탁드립니다. 감사합니다. =================================================================== 2024-03-22 06:50:22.104 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [ org.springframework.boot.actuate.health .HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServerHealthIndicator' defined in class path resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.class]: Unsatisfied dependency expressed through method 'configServerHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ' org.springframework.cloud .config.server.config.CompositeConfiguration': Unsatisfied dependency expressed through method 'setEnvironmentRepos' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository. 2024-03-22 06:50:22.113 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 2024-03-22 06:50:22.117 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2024-03-22 06:50:22.134 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2024-03-22 06:50:22.149 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Invalid config server configuration. Action: If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud .config.server.bootstrap=true, you need to use a composite configuration. ===================================================================
안녕하세요 강사님 좋은 강의 정말 감사드립니다. user service에서 어떤 요청이 들어오든 AuthenticationFilter 를 거치게 되는 것으로 알고 있는데 login 요청을 제외한 다른 요청들은(ex: health-check, welcome 등) AuthenticationFilter 에 존재하는 attemptAuthentication과 loadUserByUsername 메소드는 실행되지 않고 바로 필터가 통과되는 것인가요? 해당 질문은 msa 라기보다 시큐리티 관련 내용인 것 같아 여기에 질문하는 것이 좀 죄송한데 답변 주시면 정말 감사드리겠습니다. 감사합니다!
카프라 활용 1~2를 보면서 궁금한 점이 생겼는데 DB서 insert 가 발생했을 때는 @KafkaListener 를 통해 생성된 데이터를 받을 수 있는데 update나 delete 가 발생했을 때는 @KafkaListener로 받을 수 없더라고요? DB에서 update또는 delete문이 발생했을 때의 이벤트도 받으려면 어떻게 해야할까요?
두개의 Service가 통신할 때 예외처리 시나리오 A, B 서비스가 있을 때 A 서비스에서 B 서비스로 데이터를 수정 또는 생성하는 요청을 했는데 이 때 개발자가 의도해서 예외를 발생시켰던 예상치못한 예외가 발생했던 간에 예외가 발생해서 B서비스의 데이터를 수정하지 못하는 경우라면 A서비스는 어떻게 롤백시켜주나요? 1번 시나리오에서 하나의 서비스가 추가되어 3개의 Service가 통신할 때 예외처리 시나리오 A서비스에서 B 서비스를 수정 or 생성 하고 C서비스를 수정 or 생성하는 시나리오일 경우 만약에 B서비스에 요청을 했을 때는 성공을하고 C서비스에 요청을 했을 때 실패를 했다면 A서비스로 롤백시켜줘야하고 B서비스도 롤백을 시켜주어야할텐데 이 경우에는 어떻게 롤백처리를 해주나요?? 구글해보니 그냥 추상적으로 오케스트레이션 Saga패턴? 그런걸로 처리한다는데 막연하게 글로만 설명있고 어떤 소프트웨어를 설치해서 코드를 짜면된다 이런건 없어서 어떻게 처리되어야하는건지 감을 못잡겠네요ㅠㅠ. Axon 서버 뭐 이런것도 본거 같기도 하고요.
이번 영상에서 진행하신 모든 테스트가 작동되지 않는데 에러페이지 조차 뜨질 않아서 어떠한 오류인지 확인이 불가능하여 잘못된 점을 찾지 못하고 있습니다. 일단 Eureka 페이지에서 user-service를 클릭하면 저는 localhost 로 실행이되면서 실행권한이 없다며 접속이 불가능합니다. security filter에 걸렸나 싶었지만 그 어떤 프로젝트 파일에서도 console에 아무런 메세지가 뜨지 않습니다. 강사님께서는 따로 설정하신것이 있으실까요? 왜 저는 localhost 로 가고 강사님은 실제 ip주소로 실행되는지 이유를 잘 모르겠습니당ㅠㅠ user-ms 실행하면 Fetching이 127.0.0.1:8888로 걸리는 것 까지는 잘 되는데 그 이후에 health_check를 하고자 user-service 페이지를 여는 것부터 안됩니다ㅠㅠ
강의에서 권한을 주는 부분을 보기 전에 작성해주신 아래와 같은 Dockerfile을 사용하였을 경우 실행이 되지 않았습니다. 1번 FROM mariadb ENV MYSQL_ROOT_PASSWORD rlaxogjs8312 ENV MYSQL_DATABASE mydb COPY ./mysql_data/mysql /var/lib/mysql EXPOSE 3306 그래서 저는 복사하는 폴더가 문제인가 해서 COPY부분을 아래와 같이 바꿔서 mydb만을 복사하도록 하였습니다. 2번 FROM mariadb ENV MYSQL_ROOT_PASSWORD rlaxogjs8312 ENV MYSQL_DATABASE mydb COPY ./mysql_data/mysql/mydb /var/lib/mysql EXPOSE 3306 이렇게 하였더니 db가 제대로 복사가 되지는 않았지만 로컬에서 접속이 가능하였습니다. 그래서 왜 복사가 안되는거지.. 고민하다가 나머지 강의를 듣고 다시 1번으로 빌드 후 실행한 뒤에는 복사도 잘 되었음을 확인하였습니다. 궁금한 점은 다음과 같습니다. 왜 2번 Dockerfile의 경우 복사는 제대로 되지 않았는데 로컬호스트에서 DB에 접속이 가능했었던 건지 궁금합니다. 만약 COPY가 아니라 VOLUME을 적용해서 한 과거 기억을 되살려보면 권한은 문제가 없었던 것 같은데 권한은 해당 Docker Container에 어떤 이유때문에 적용해야하는 것인지 궁금합니다.
userService의 로그입니다. orderService의 로그입니다. git에 올리신 springboot 3번대로 설정한 결과입니다. 강의에서는, get /user-service/users/{user-id} 호출시 feign client로 orderService로 호출을 하고 userServicedptjdml traceId 와 orderService에서의 traceId 가 동일하다고 설명하셨는데, 직접 해본결과 api호출은 문제없이 되나 두개의 traceId가 다르게 나오는 현상입니다. zipkin에서 확인해봐도 userService -> orderService로 호출되는 형태로 나오지 않고, 각각 따로 나오는 형태입니다. 뭐가문제일까요. userService와 orderService의 application.yml입니다.
Dockerfile 내용 FROM mariadb ENV MYSQL_ROOT_PASSWORD test1357 ENV MYSQL_DATABASE mydb COPY ./mysql_data/mysql /var/lib/mysql EXPOSE 3306 ENTRYPOINT ["mariadb", "--user=root"] 실습환경 windows 10 mysql_data\mysql 내용 에러 메시지 ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
docker compose 명령어를 사용하면 강의와 다르게 에러가 뜨고 있습니다. docker compose 에서 생성한 네트워크가 아니라는 말도 있는데 혼자서는 해결이 안되고 있네요. https://github.com/wurstmeister/kafka-docker 위 git을 클론하여 실습했습니다. 실습환경 windows 10 사용한 명령어 docker-compose -f docker-compose-single-broker.yml up -d 에러메시지 time="2024-02-23T17:46:21+09:00" level=warning msg="a network with name ecommerce-network exists but was not created by compose.\nSet `external: true` to use an existing network" network ecommerce-network was found but has incorrect label com.docker.compose.network set to "" docker-compose-single-broker.yml 내용 version: '2' services: zookeeper: image: wurstmeister/zookeeper ports: - "2181:2181" networks: my-network: ipv4_address: 172.18.0.100 kafka: # build: . image: wurstmeister/kafka ports: - "9092:9092" environment: KAFKA_ADVERTISED_HOST_NAME: 172.18.0.101 KAFKA_CREATE_TOPICS: "test:1:1" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 volumes: - /var/run/docker.sock:/var/run/docker.sock depends_on: - zookeeper networks: my-network: ipv4_address: 172.18.0.101 networks: my-network: name: ecommerce-network