| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
- kotlin
- 안드로이드스튜디오
- 프론트엔드
- include이벤트처리
- hilt오류
- Hilt
- 안드로이드로딩창
- SpringWebFlux
- 종속항목삽입
- 리사이클러뷰
- include태그
- SpringBoot
- 자바
- 안드로이드 스튜디오
- glide
- 공공데이터포털리사이클러뷰
- 안드로이드 스튜디오 JAVA
- 데이터바인딩
- 안드로이드 스튜디오 API
- Today
- Total
내일은개발왕
[Springboot] Spring API Gateway + SpringWebFlux 로그인 폼 제발 사라져줘 제발;;; 본문
📌 해결하기전에 잠깐! 개념 짚고 가자~
Spring Cloud Gateway : Spring web Flux, Project Reactor 를 기반으로 구축된 Routing 및 보안 기능등을 제공하는 API Gateway다.
Routing : 사전의 뜻처럼 경로를 지정해주는 역할을 한다. ex) http://a.com 으로 요청이 오면 http://b.com으로 연결
Gateway : 다른 네트워크로 접속하기 위해 거치는 관문, 즉 게이트 웨이는 A에서 오는 요청을 다른 곳으로 보내주는 역할을 한다고 이해하면 편하다.
🚨 문제 상황
spring cloud GateWay 프로젝트에 관련 의존성을 추가해주고 local에서 테스트 시 security login폼이 계속 뜨는 상황
👍해결
Spring Cloud Gateway는 공식 문서에 기술되어 있는 것처럼 기본적으로 spring WebFlux로 구현되어 있다.
그래서 기본적으로 security가 포함이 되어 있긴한데 다른 점은, 이친구는 WebFluxSecurity를 사용한다.
그렇기에 아무리 spring security를 사용해 form을 disable 해도 먹히지 않았던 것이 원인이었다.
이를 해결하기 위해서, 새로운 java class 파일 하나 만들어 주고, 아래와 같은 코드를 작성해주면 된다.
혹시 모르니 의존성도 추가했다.
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.7.0'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework:spring-webflux:6.2.2'
implementation 'io.grpc:grpc-netty:1.70.0'
}
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@EnableWebFluxSecurity //WebFluxSecurity를 조정해줘야함
public class WebFluxSecurityConfig {
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http){
//return http. 이렇게해서 필요한 부분들 조정해주면 gate way에 적용이 된다.
}
}
진짜 ㅋㅋ 이거 하나 잡겠다고 회사에서 이틀간 난리쳤는데 안되서 어제 집에서 해결했다 ㅋ.....
하.......... 개킹받음 그래도 이거 절대 안까먹을듯 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway/starter.html
How to Include Spring Cloud Gateway :: Spring Cloud Gateway
If you include the starter, but you do not want the gateway to be enabled, set spring.cloud.gateway.enabled=false.
docs.spring.io
'오류삽질,기타삽질' 카테고리의 다른 글
| [안드로이드 스튜디오] - Hilt구요 저도 에러를 낼거에요 ㅎㅎ - @Qualifier retrofit 사용시 (0) | 2024.05.24 |
|---|---|
| [안드로이드 스튜디오] 안녕 난 공백문자야 그리고 오류를 낼거야 (0) | 2024.05.13 |
| [build.gradle] fragment directions 생성이 안돼. (0) | 2024.05.10 |
| [build.gradle오류] roomDB가 존재하지 않습니다. 장비를 파괴합니다. (0) | 2024.05.09 |
| [안드로이드 스튜디오] Glide 이미지가 복사가 된다! 와! 왜..? (1) | 2024.02.16 |