Skip to content

Commit

Permalink
fix: prioritize login page route to prevent single page override (#6926)
Browse files Browse the repository at this point in the history
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x

#### What this PR does / why we need it:
修复登录页面路由会被自定义页面覆盖导致无法登录的问题

#### Which issue(s) this PR fixes:
Fixes #6893

#### Does this PR introduce a user-facing change?
```release-note
修复登录页面路由会被自定义页面路由覆盖导致无法登录的问题
```
  • Loading branch information
guqing authored Oct 23, 2024
1 parent 17ec34c commit 2c234ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import lombok.Data;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
Expand Down Expand Up @@ -55,6 +57,7 @@ public PreAuthEmailPasswordResetEndpoint(
}

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 100)
RouterFunction<ServerResponse> preAuthPasswordResetEndpoints(
GlobalInfoService globalInfoService,
PasswordResetAvailabilityProviders availabilityProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.web.server.savedrequest.ServerRequestCache;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.RouterFunction;
Expand Down Expand Up @@ -53,6 +55,7 @@ class PreAuthLoginEndpoint {
}

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 100)
RouterFunction<ServerResponse> preAuthLoginEndpoints() {
return RouterFunctions.nest(path("/login"), RouterFunctions.route()
.GET("", request -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.net.URI;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -67,6 +69,7 @@ class PreAuthSignUpEndpoint {
}

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 100)
RouterFunction<ServerResponse> preAuthSignUpEndpoints() {
return RouterFunctions.nest(path("/signup"), RouterFunctions.route()
.GET("", request -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Map;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
Expand All @@ -19,6 +21,7 @@
class PreAuthTwoFactorEndpoint {

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 100)
RouterFunction<ServerResponse> preAuthTwoFactorEndpoints(GlobalInfoService globalInfoService) {
return RouterFunctions.route()
.GET("/challenges/two-factor/totp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -86,6 +88,7 @@ public class SystemSetupEndpoint {
private final ObjectProvider<R2dbcConnectionDetails> connectionDetails;

@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 100)
RouterFunction<ServerResponse> setupPageRouter() {
final var tag = "SystemV1alpha1Public";
return SpringdocRouteBuilder.route()
Expand Down

0 comments on commit 2c234ab

Please sign in to comment.