Create route in Spring Cloud Gateway with OAuth2 Resource Owner Password grant type

后端 未结 1 425
时光取名叫无心
时光取名叫无心 2021-01-22 14:37

How to configure a route in Spring Cloud Gateway to use an OAuth2 client with authorization-grant-type: password? In other words, how to add the Authorization heade

1条回答
  •  爱一瞬间的悲伤
    2021-01-22 15:21

    I implemented authorization-grant-type: password using WebClientHttpRoutingFilter.

    By default, spring cloud gateway use Netty Routing Filter but there is an alternative that not requires Netty (https://cloud.spring.io/spring-cloud-gateway/reference/html/#the-netty-routing-filter)

    WebClientHttpRoutingFilter uses WebClient for route the requests.

    The WebClient can be configured with a ReactiveOAuth2AuthorizedClientManager through of an ExchangeFilterFunction (https://docs.spring.io/spring-security/site/docs/current/reference/html5/#webclient). The ReactiveOAuth2AuthorizedClientManager will be responsible of management the access/refresh tokens and will do all the hard work for you

    Here you can review this implementation. In addition, I implemented the client-credentials grant with this approach

    0 讨论(0)
提交回复
热议问题