Spring boot oauth2,如何获取认证前的初始请求?
Spring boot oauth2, how to retrieve the initial request before authentication?
我正在使用以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
我为端点 /login
启用了 oauth2,现在当我在成功验证后访问 url /login?foo=bar
时,我被重定向到路径 /
。我知道我可以使用 ServerAuthenticationSuccessHandler.setLocation()
方法设置重定向 url,但我希望能够使用查询参数 foo
及其值 bar
重定向到页面 success.html ],类似于 /success.html?foo=bar
,我如何检索最初在身份验证之前向登录端点发出的请求?
我发现了问题,spring oauth2 客户端的默认行为是重定向到受保护的资源,在我的例子中我限制了 /foo/login
端点但从 [=11= 开始了身份验证] 端点,这就是 spring 没有重定向到受保护资源的原因。
我正在使用以下依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
我为端点 /login
启用了 oauth2,现在当我在成功验证后访问 url /login?foo=bar
时,我被重定向到路径 /
。我知道我可以使用 ServerAuthenticationSuccessHandler.setLocation()
方法设置重定向 url,但我希望能够使用查询参数 foo
及其值 bar
重定向到页面 success.html ],类似于 /success.html?foo=bar
,我如何检索最初在身份验证之前向登录端点发出的请求?
我发现了问题,spring oauth2 客户端的默认行为是重定向到受保护的资源,在我的例子中我限制了 /foo/login
端点但从 [=11= 开始了身份验证] 端点,这就是 spring 没有重定向到受保护资源的原因。