Improve TokenRelay filter documentation when Gateway acts as a BFF
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 58/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- java, spring-boot
調査の方向性
The target is the TokenRelay filter reference page for the WebMVC gateway, which is documentation, not code. Read the existing filter section, then compare it with the reporter's SecurityFilterChain example, which sets oauth2Login success handling, oidcLogout, a logout success handler, and csrf.spa(). Done means the page explains which of these settings a BFF needs for post-login and post-logout redirects. The multi-frontend whitelist idea is a design question and is out of scope.
索引モデルが issue の本文から書いたものです。
説明
Here, using BFF and token relay patterns becomes popular (see https://datatracker.ietf.org/doc/rfc10017).
TokenRelayFilter works but requires some tweaks for proper redirection after login and logout.
I think this page https://docs.spring.io/spring-cloud-gateway/reference/spring-cloud-gateway-server-webmvc/filters/tokenrelay.html could give more details about the settings required to have a working BFF.
Here is what I have:
@Bean
SecurityFilterChain oauth2SecurityFilterChain(HttpSecurity http, ClientRegistrationRepository registrations) {
String frontendUrl = "http://localhost:9000";
var authenticationSuccessHandler = new SimpleUrlAuthenticationSuccessHandler(frontendUrl);
var logoutSuccessHandler = new OidcClientInitiatedLogoutSuccessHandler(registrations);
logoutSuccessHandler.setPostLogoutRedirectUri(frontendUrl);
http.oauth2Login(cust -> cust.successHandler(authenticationSuccessHandler));
http.oauth2Client(withDefaults());
http.oidcLogout(oidc -> oidc.backChannel(Customizer.withDefaults()));
http.logout(cust -> cust.logoutSuccessHandler(logoutSuccessHandler));
http.csrf(x -> x.spa());
return http.build();
}
The frontend URL must be a valid redirect URL (OIDC client settings) otherwise redirect after logout fails.
Using
var logoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
logoutSuccessHandler.setDefaultTargetUrl(frontendUrl);
is a kind of trap because it invalidates the session at the gateway level but does not call OIDC server so at the OIDC server level the user is still logged.
The frontend url can be declared as a custom property but there will still be is a 1-1 relationship between the BFF and the frontend. It respects the "backend for frontend" semantic ("frontend" is singular) but frontend url could be transmitted in the URL when the client logs in (GET on http://bff/oauth2/authorization/+registrationid) and saved in session for the final redirection. A whitelist of approved frontends could be declared somewhere. Adding a BFF make the infrastructure more complex so if a single BFF can serve several frontends it fosters adoption.
- 主要言語
- Java
- スター
- 4.9k
- フォーク
- 3.5k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-cloud/spring-cloud-gateway のほかの issue
-
RequestRateLimiterGatewayFilterFactory commits 429 response instead of throwing対応中かも @seonwooj0810 が 155 日前に担当しました。 オープンwaiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spring-cloud/spring-cloud-gateway#4175 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add @Order annotation to gatewayRestClientCustomizer Bean対応中かも @CheHyeonYeong が 227 日前に担当しました。 オープンenhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spring-cloud/spring-cloud-gateway#3626 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Ambiguity in section 19 of the documentation - Spring Cloud Gateway - Custom Route Predicate対応中かも @won-seoop が 154 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
spring-cloud/spring-cloud-gateway#3463 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
spring-cloud/spring-cloud-gateway#4357 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
spring-cloud/spring-cloud-gateway#4341 ·
メンテナーはふだん 1 日以内に返信
spring-cloud/spring-cloud-gateway の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
langchain4j/langchain4j#7068 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
opensearch-project/k-NN#3693 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Encrypted PDF portfolios show an empty portfolio panel対応中かも @christophmertins が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Stirling-Tools/Stirling-PDF#8864 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
CodingDocs/awesome-java#41 · コメント 1 件 ·