Improve TokenRelay filter documentation when Gateway acts as a BFF
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 58/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java, spring-boot
- Lĩnh vực
- authentication, documentation
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 4.9k
- Fork
- 3.5k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của spring-cloud/spring-cloud-gateway
-
RequestRateLimiterGatewayFilterFactory commits 429 response instead of throwingCó thể đã có người làm @seonwooj0810 đã nhận 155 ngày trước. Đang mởwaiting-for-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spring-cloud/spring-cloud-gateway#4175 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add @Order annotation to gatewayRestClientCustomizer BeanCó thể đã có người làm @CheHyeonYeong đã nhận 227 ngày trước. Đang mởenhancement help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
spring-cloud/spring-cloud-gateway#3626 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Ambiguity in section 19 of the documentation - Spring Cloud Gateway - Custom Route PredicateCó thể đã có người làm @won-seoop đã nhận 154 ngày trước. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
spring-cloud/spring-cloud-gateway#3463 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
spring-cloud/spring-cloud-gateway#4357 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
waiting-for-triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
spring-cloud/spring-cloud-gateway#4341 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của spring-cloud/spring-cloud-gateway
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
langchain4j/langchain4j#7068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
opensearch-project/k-NN#3693 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Disk full for windows GH actionĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Encrypted PDF portfolios show an empty portfolio panelCó thể đã có người làm @christophmertins đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Stirling-Tools/Stirling-PDF#8864 · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
CodingDocs/awesome-java#41 · 1 bình luận ·