在 spring oauth2 客户端中处理令牌响应

时间:2021-05-31 07:03:38

标签: spring oauth spring-cloud spring-webflux spring-cloud-gateway

我使用 Spring Cloud Gateway 作为我们系统的 API 网关。我们希望将所有身份验证 (oauth) 委托给该组件。我正在查看 Spring Oauth2 Client 的源代码,但我没有看到任何可以“插入”以执行所需操作的地方。

我想抓住代码交换成功的时刻,并在 cookie 或查询参数中使用 id_tokenrefresh_token 进行重定向。我们也不存储任何会话 - 整个身份验证都是无状态的。

我正在像这样配置 SecurityWebFilterChain(WebFlux 的安全性):

@Bean
  public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
  http
      .authorizeExchange(Customizer.withDefaults())
      .oauth2Login();
    http.csrf().disable();
    return http.build();
  }

我尝试使用successHandler .oauth2Login(c -> c.authenticationSuccessHandler(successHandler));,但在那一刻我无法访问 refresh_token(只有 WebFilterExchange,参数中的身份验证),我什至不确定我应该如何在那个地方执行重定向表单。

有什么办法可以实现吗?

0 个答案:

没有答案