【问题标题】:Use OAuth2 with Spring Security OAuth2 and reactor netty in a webflux project without servlet api在没有 servlet api 的 webflux 项目中使用 OAuth2 和 Spring Security OAuth2 和 reactor netty
【发布时间】:2020-02-06 02:10:41
【问题描述】:

我想将 webflux 与 reactor netty 一起使用,但是我的项目依赖于 spring-security-oauth2 ,特别是使用 https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/OAuth2Authentication.java 类来使用 oauth2,但是这个项目使用了 servlet api,而 netty 不支持小服务程序 API。可以在 spring-security-oauth2 项目中使用 reactor netty 吗?

【问题讨论】:

    标签: java spring-boot spring-security-oauth2 spring-webflux reactor-netty


    【解决方案1】:

    是的,spring-security-oauth2 已被提升到 Spring security 5 中,不再是一个独立的库。

    Spring security 5 也支持 webflux。

    Webflux security

    【讨论】:

    • 嗨@thomas,我看过他们的blog postfaq,但他们provide 的样本依赖于spring-security-oauth2-client
    • security-oauth2-client 依赖于 servlet api,如您所见 here 。在我的情况下,我不想使用提供 servlet api 的 tomcat、jetty 或 undertow,但我想在 webflux 中使用不是 servlet 容器的 reactor netty。
    • 我认为你搞错了。仅仅因为您对 servlet api 有依赖并不意味着您正在运行 tomcat/jetty 或 undertow。 Webflux 不能与 netty 以外的任何东西一起使用。因此,一旦您选择了 webflux,您就会自动获得 netty 作为底层实现。 servlet api 只是一组接口。
    • 我知道这并不意味着我需要 tomcat 或其他 servlet 容器,但正如您所见 here ,servlet-api 需要在运行时由 servlet 容器提供。即使只是将此依赖项添加到我的 netty 项目中,该项目也将无法运行,因为依赖项需要由 servlet 容器提供,在本例中为 tomcat、jetty 或 undertow。如果您认为还有其他选择,请告诉我。
    • 你不要添加那个依赖,你需要的所有类都包含在 spring 安全库中。该库已弃用。
    猜你喜欢
    • 2014-09-15
    • 2019-09-25
    • 2017-09-01
    • 2017-10-02
    • 1970-01-01
    • 2017-04-04
    • 2021-08-17
    • 1970-01-01
    • 2014-11-03
    相关资源
    最近更新 更多