簡體   English   中英

SpringBoot oAuth2 位置 Header

[英]SpringBoot oAuth2 Location Header

我有三個微服務

  • 網關(Spring Cloud 網關)
  • 安全
  • 保險

所有請求都發送到端口 8080 上的網關服務,將它們重定向到特定服務

@Bean
    public RouteLocator myRoutes (
            RouteLocatorBuilder builder
    ) {
        return builder.routes()
                .route(p -> p.path("/auth/**")
                        .filters(f -> f.rewritePath("^/auth", ""))
                        .uri(authServiceUri))
                .route(p -> p
                        .path("/payments/**")
                        .filters(f -> f.rewritePath("^/payments", ""))
                        .uri(paymentServiceUri)
                )
                .route(p -> p
                        .path("/insurance/**")
                        .filters(f -> f.rewritePath("^/insurance", ""))
                        .uri(insuranceServiceUri)
                )
                .build();
    }

如果我導航到 /insurance oAuth 將我重定向到登錄頁面(api.domain.com/auth/login),然后使用用戶憑據(api.domain.com/auth/login)的登錄表單發出 POST 請求,此請求(如果成功)包含一個 Location Header,它將用戶重定向到 /oauth/authorize 端點。

The problem is that this header does not contain the gateway service URL (api.domain.com:8080/auth) but it contains the direct service url (http://localhost:9999) how can i fix this? 如何告訴 Spring oAuth 將重定向發送回網關服務器而不是服務 url?

在此處輸入圖像描述

在 Auth 服務器上添加以下屬性:

server.forward-headers-strategy=framework

可以在Spring 文檔中找到有關這方面的一些附加信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM