【问题标题】:Securing SpringBoot REST endpoints in Google Cloud Platform在 Google Cloud Platform 中保护 SpringBoot REST 端点
【发布时间】:2018-06-14 13:39:02
【问题描述】:

我创建了一个带有几个 REST 端点的 SpringBoot 应用程序,并将其部署到 Google App Engine Standard。一切正常,我能够达到终点。 现在我想保护这些端点,并只允许授权为管理员的用户能够调用其中一个端点。我尝试使用以下配置将 web.xml 文件添加到我的项目中:

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<security-constraint>
    <web-resource-collection>
        <web-resource-name>api</web-resource-name>
        <url-pattern>/api/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>status</web-resource-name>
        <url-pattern>/api/status</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>ping</web-resource-name>
        <url-pattern>/api/ping</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
    </security-constraint>

我可以将它部署到 GAE,但我不能再调用端点。我现在得到的只是一堆未找到的 404,在与以前相同的 URL 上。有没有其他方法可以保护 Google App Engine Standard 中的 SpringBoot 端点?

忘了提到当我在本地运行应用程序时安全配置有效,但一部署到 GAE 就开始出现 404。

【问题讨论】:

    标签: rest google-app-engine spring-boot spring-security


    【解决方案1】:

    联系 Google Cloud 支持后,无法使用 Google APP 引擎配置文件保护 Spring 应用程序。它需要像任何其他 Spring 应用程序一样完成,但如果您使用 OAUTH,例如,您需要使用 Google 库进行令牌身份验证。

    【讨论】:

      猜你喜欢
      • 2021-07-17
      • 2021-07-18
      • 2014-04-16
      • 2020-02-17
      • 2016-03-04
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 1970-01-01
      相关资源
      最近更新 更多